Skip to content

Commit

Permalink
fix: assert method and use correct key for server middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Apr 7, 2022
1 parent b9d32cf commit 8a4d631
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ export default defineNuxtModule<ModuleOptions>({
name: '@nuxtjs/supabase',
configKey: 'supabase',
compatibility: {
nuxt: '^3.0.0 || ^2.16.0',
bridge: true
nuxt: '^3.0.0'
}
},
defaults: {
Expand Down Expand Up @@ -94,7 +93,7 @@ export default defineNuxtModule<ModuleOptions>({

// Add supabase session endpoint to store the session on server-side
addServerMiddleware({
path: '/api/_supabase/session',
route: '/api/_supabase/session',
handler: resolve(runtimeDir, 'server/api/session')
})

Expand Down
3 changes: 2 additions & 1 deletion src/runtime/server/api/session.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { IncomingMessage, ServerResponse } from 'http'
import { useBody, setCookie } from 'h3'
import { useBody, setCookie, assertMethod } from 'h3'
import { useRuntimeConfig } from '#nitro'

const config = useRuntimeConfig()

export default async (req: IncomingMessage, res: ServerResponse) => {
assertMethod(req, 'POST')
const body = await useBody(req)
const cookieOptions = config.supabase.cookies

Expand Down

0 comments on commit 8a4d631

Please sign in to comment.