This commit is contained in:
parent
dcb30caafb
commit
6354af6ea1
|
|
@ -10,7 +10,7 @@ import { cookies } from "next/headers"
|
|||
import { ReactNode } from "react"
|
||||
import "./globals.css"
|
||||
import { Suspense } from "react"
|
||||
import { RuntimeEnvProvider } from "@/components/utility/runtime-env-provider"
|
||||
import { RuntimeEnvScript } from "@/components/utility/runtime-env-script"
|
||||
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] })
|
||||
|
|
@ -105,7 +105,7 @@ export default async function RootLayout({
|
|||
<html lang="en" suppressHydrationWarning>
|
||||
|
||||
<head>
|
||||
<RuntimeEnvProvider />
|
||||
<RuntimeEnvScript />
|
||||
</head>
|
||||
|
||||
<body className={inter.className}>
|
||||
|
|
|
|||
|
|
@ -92,12 +92,10 @@
|
|||
// }
|
||||
|
||||
|
||||
// components/utility/runtime-env-provider.tsx
|
||||
// components/utility/runtime-env-script.tsx
|
||||
import { headers } from "next/headers"
|
||||
import { useServerInsertedHTML } from "next/navigation"
|
||||
import React from "react"
|
||||
|
||||
export function RuntimeEnvProvider() {
|
||||
export function RuntimeEnvScript() {
|
||||
const h = headers()
|
||||
|
||||
const proto =
|
||||
|
|
@ -107,18 +105,13 @@ export function RuntimeEnvProvider() {
|
|||
|
||||
const supabaseUrl = `${proto}://${hostname}:8000`
|
||||
|
||||
useServerInsertedHTML(() => {
|
||||
return (
|
||||
<script
|
||||
id="runtime-env"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.RUNTIME_ENV = { SUPABASE_URL: ${JSON.stringify(
|
||||
supabaseUrl
|
||||
)} };`,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
||||
return null
|
||||
return (
|
||||
<script
|
||||
id="runtime-env"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.RUNTIME_ENV = { SUPABASE_URL: ${JSON.stringify(supabaseUrl)} };`,
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue