feat: graphql client with fetches for initial pages
This commit is contained in:
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// @ts-check
|
||||
/**
|
||||
* This file is included in `/next.config.mjs` which ensures the app isn't built with invalid env vars.
|
||||
* It has to be a `.mjs`-file to be imported there.
|
||||
*/
|
||||
import { serverSchema, serverEnv } from './schema.mjs'
|
||||
import { env as clientEnv, formatErrors } from './client.mjs'
|
||||
|
||||
const _serverEnv = serverSchema.safeParse(serverEnv)
|
||||
|
||||
if (!_serverEnv.success) {
|
||||
const msg = [
|
||||
'❌ Invalid environment variables [Server]:\n',
|
||||
...formatErrors(_serverEnv.error.format()),
|
||||
].join('')
|
||||
console.error(msg)
|
||||
throw new Error(msg)
|
||||
}
|
||||
|
||||
for (let key of Object.keys(_serverEnv.data)) {
|
||||
const msg = []
|
||||
if (key.startsWith('NEXT_PUBLIC_')) {
|
||||
msg.push(
|
||||
`❌ You are exposing a server-side env-variable: ${key}\n`
|
||||
)
|
||||
}
|
||||
if (msg.length) {
|
||||
console.warn(msg.join(''))
|
||||
throw new Error(msg.join(''))
|
||||
}
|
||||
}
|
||||
|
||||
export const env = { ..._serverEnv.data, ...clientEnv }
|
||||
Reference in New Issue
Block a user