Jack M
Jack M
CDCloudflare Developers
Created by Jack M on 6/10/2024 in #pages-help
Trouble deploying Auth.js with Sveltekit on Cloudflare Pages - `node:crypto`
I was able to solve this by explicitly installing @auth/core. For any future searchers, related issue is https://github.com/nextauthjs/next-auth/issues/11184
5 replies
CDCloudflare Developers
Created by Jack M on 6/10/2024 in #pages-help
Trouble deploying Auth.js with Sveltekit on Cloudflare Pages - `node:crypto`
Eventually I tracked down this issue from jose, which is a library used by auth.js, but it seems to just suggest disabling node compat... which breaks other things 😬
5 replies
CDCloudflare Developers
Created by Jack M on 6/10/2024 in #pages-help
Trouble deploying Auth.js with Sveltekit on Cloudflare Pages - `node:crypto`
Currently, the vite.config.ts is fairly stock:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [
sveltekit()
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
});
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [
sveltekit()
],
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
},
});
I've tried using resolve:{alias:{}} to try and polyfill it, but I'm not massively familiar with Vite, and that may be more of a sveltekit issue anyway. The wrangler.toml currently looks like this:
name = "dms-hgm"
pages_build_output_dir = ".svelte-kit/cloudflare"
compatibility_date = "2024-05-13"
compatibility_flags = [ "nodejs_compat", "nodejs_als" ]

[vars]
AUTH_MICROSOFT_ENTRA_ID = "<REDACTED>"
AUTH_MICROSOFT_ENTRA_TENANT_ID = "<REDACTED>"

[[d1_databases]]
database_id = "<REDACTED>"
binding = "DB"
database_name = "dms-hgm"
preview_database_id = "DB" # Required for Pages local development

[env.production]
compatibility_date = "2023-11-15"

[env.production.vars]
AUTH_MICROSOFT_ENTRA_ID = "<REDACTED>"
AUTH_MICROSOFT_ENTRA_TENANT_ID = "<REDACTED>"

[[env.production.d1_databases]]
database_id = "<REDACTED>"
binding = "DB"
database_name = "DB"
name = "dms-hgm"
pages_build_output_dir = ".svelte-kit/cloudflare"
compatibility_date = "2024-05-13"
compatibility_flags = [ "nodejs_compat", "nodejs_als" ]

[vars]
AUTH_MICROSOFT_ENTRA_ID = "<REDACTED>"
AUTH_MICROSOFT_ENTRA_TENANT_ID = "<REDACTED>"

[[d1_databases]]
database_id = "<REDACTED>"
binding = "DB"
database_name = "dms-hgm"
preview_database_id = "DB" # Required for Pages local development

[env.production]
compatibility_date = "2023-11-15"

[env.production.vars]
AUTH_MICROSOFT_ENTRA_ID = "<REDACTED>"
AUTH_MICROSOFT_ENTRA_TENANT_ID = "<REDACTED>"

[[env.production.d1_databases]]
database_id = "<REDACTED>"
binding = "DB"
database_name = "DB"
5 replies