Closed Q16solver closed 1 year ago
What is your production environment ? It should support crypto.getRandomValues
as it's an auth.js requirement. This should be polyfilled by unenv or by this module directly.
I'm using railway to deploy which has node v16 and npm v9. Though yeah, interestingly enough, it does say in the logs that it's polyfilled crypto module.
> nuxt preview
[log]
╭───────────────────────────────────Preview Mode─────────────────────────────────────╮
│ │
│ You are running Nuxt production build in preview mode. │
│ For production deployments, please directly use node ./server/index.mjs command. │
│ │
│ Node.js: v16.18.1 │
│ Nitro Preset: node-server │
│ Working directory: .output │
│ │
╰────────────────────────────────────────────────────────────────────────────────────╯
[info] Loading `.env`. This will not be loaded when running the server in production.
[info] Starting preview command: `node ./server/index.mjs`
[log]
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P06',
message: 'schema "drizzle" already exists, skipping',
file: 'schemacmds.c',
line: '118',
routine: 'CreateSchemaCommand'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '209',
routine: 'transformCreateStmt'
}
Polyfilling crypto...
Listening on http://[::]:6072
WebSocket Server is listening
Removing session
I'm using railway to deploy which has node v16 and npm v9. Though yeah, interestingly enough, it does say in the logs that it's polyfilled crypto module.
> nuxt preview [log] ╭───────────────────────────────────Preview Mode─────────────────────────────────────╮ │ │ │ You are running Nuxt production build in preview mode. │ │ For production deployments, please directly use node ./server/index.mjs command. │ │ │ │ Node.js: v16.18.1 │ │ Nitro Preset: node-server │ │ Working directory: .output │ │ │ ╰────────────────────────────────────────────────────────────────────────────────────╯ [info] Loading `.env`. This will not be loaded when running the server in production. [info] Starting preview command: `node ./server/index.mjs` [log] { severity_local: 'NOTICE', severity: 'NOTICE', code: '42P06', message: 'schema "drizzle" already exists, skipping', file: 'schemacmds.c', line: '118', routine: 'CreateSchemaCommand' } { severity_local: 'NOTICE', severity: 'NOTICE', code: '42P07', message: 'relation "__drizzle_migrations" already exists, skipping', file: 'parse_utilcmd.c', line: '209', routine: 'transformCreateStmt' } Polyfilling crypto... Listening on http://[::]:6072 WebSocket Server is listening Removing session
The polyfill is something that I tried to do there https://github.com/Hebilicious/authjs-nuxt/blob/2100f25fd7de00095e00b330db3c3e29c22d1209/packages/authjs-nuxt/src/runtime/lib/server.ts#L9 , although I haven't tested it under all conditions, and it looks like it isn't working with node 16.
For railway, it looks like you can use a more recent version of node, or even try out bun https://docs.railway.app/deploy/builds . Btw Node 16 as reached EOL so you should not use it anymore.
I would also recommend that you never run your production app with Nuxt preview, instead run the built version with node .output/server/index.mjs
https://nuxt.com/docs/getting-started/deployment
Yeah, seems like that was the issue, updated to use node 18 and works now, I'll also update to run the js file directly, thanks for the advice c:
Environment
Reproduction
N/A
Describe the bug
Running signIn function in production gives me a crypto module error for some reason
Additional context
No response
Logs