Closed michaelsieminski closed 3 months ago
Please do not use server middleware that throw error like this:
if (event.method !== 'GET') {
const originHeader = getHeader(event, 'Origin') ?? null
const hostHeader = getHeader(event, 'Host') ?? null
if (
!originHeader ||
!hostHeader ||
!verifyRequestOrigin(originHeader, [hostHeader])
) {
throw createError({ statusCode: 403 })
}
}
This will prevent NuxtHub remote storage to work.
Please do not use server middleware that throw error like this:
if (event.method !== 'GET') { const originHeader = getHeader(event, 'Origin') ?? null const hostHeader = getHeader(event, 'Host') ?? null if ( !originHeader || !hostHeader || !verifyRequestOrigin(originHeader, [hostHeader]) ) { throw createError({ statusCode: 403 }) } }
This will prevent NuxtHub remote storage to work.
Oh okay thank you! Is there an alternative for Nuxt to handle CSRF Protection?
I have removed this part but it seems like the same error is being thrown still
Did you deploy using the nuxthub deploy
command or Cloudflare Pages CI or do you self-host?
Did you deploy using the
nuxthub deploy
command or Cloudflare Pages CI or do you self-host?
I am using nuxthub deploy
Solved on Discord.
The solution is to avoid using useDatabase()
outside of the server eventHandlers
.
So if you use useDatabase()
in a server util, it should be wrapper into a function (ex: useLucia()
)
Describe the bug I am using NuxtHub DB with Drizzle and Lucia Auth and did everything like in the docs. It seems to work locally but when deploying im getting the following Error:
I am also locally using the --remote flag so it uses the remote database from Cloudflare already but it still seems to break on Deployment
Reproduction link from someone who also had the issue: https://stackblitz.com/~/github.com/rktmatt/help-drizzle-nuxt-hub
Expected behavior It should work and not have missing cloudflare DB bindings