-
Environment
Reproduction URLnull Describe the issueI'm using vite-plugin-ssr with NextAuth.js, I'm facing the error It looks like that NextAuth is directly using Next.js does indeed expose a As a workaround, add this line to your HTML: <script>self.process = { env: {} }</script> How to reproducenull Expected behaviornull |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 12 replies
-
|
Beta Was this translation helpful? Give feedback.
-
@balazsorban44 It's unclear to me how Next.js is exposing environment variables to the client like |
Beta Was this translation helpful? Give feedback.
-
install define: {
"process.env": process.env,
} |
Beta Was this translation helpful? Give feedback.
-
@Sajad-Sharhani Defining the What I don't understand is that these variables are not prefixed by |
Beta Was this translation helpful? Give feedback.
-
Check the official NextAuth.js vite-plugin-ssr docs at https://vite-plugin-ssr.com/NextAuth.js. |
Beta Was this translation helpful? Give feedback.
-
@brillout Man that's awesome! So exposing environment variables with custom prefixes to the client is possible in Vite! Since you've updated the docs, consider mentioning that a fetch polyfill in node is needed in order to use import fetch, { Headers, Request, Response } from 'cross-fetch'
if (!globalThis.fetch) {
globalThis.fetch = fetch
globalThis.Headers = Headers
globalThis.Request = Request
globalThis.Response = Response
} |
Beta Was this translation helpful? Give feedback.
Check the official NextAuth.js vite-plugin-ssr docs at https://vite-plugin-ssr.com/NextAuth.js.