nuxt-modules / supabase

Supabase module for Nuxt.
https://supabase.nuxtjs.org
MIT License
706 stars 129 forks source link

404 error on API session route #39

Closed SeraVault closed 2 years ago

SeraVault commented 2 years ago

When trying to login to supabase using useSupabaseClient() using v0.1.14, I'm getting a 404 error:

POST http://localhost:3000/api/_supabase/session 404 (Page not found: /api/_supabase/session)

It works fine on v 1.1.10. Is there any additional configuration necessary on v0.1.14?

Thanks

larbish commented 2 years ago

Hi @SeraVault, nothing has changed on login between those two versions. Can you provide a reproduction ?

atinux commented 2 years ago

How do you deploy your project @SeraVault ?

SeraVault commented 2 years ago

I'm just using a local dev server at the moment (nuxt dev). I'll see if I can provide a reproduction. Thanks.

daanvangeloven commented 2 years ago

I am currently struggling with the same issue. Has a cause been for this issue been found? When I try magic link login on my local dev server I get this line in console: [Vue Router warn]: No match found for location with path "/api/_supabase/session"

The url looks like this after the issue: http://localhost:3000/login#error_code=404&error_description=User+not+found

I had not changed anything on the login side when it stopped working. I tried reverting the module to 1.1.10 as stated above but that also didn't fix my issue.

larbish commented 2 years ago

I am not able to reproduce this error. Can one of you provide a stackblitz reproduction ? 🙏

daanvangeloven commented 2 years ago

@larbish I hope this helps: reproduction

I'm very new to nuxt3 and supabase so it's most likely a mistake on my part. Please let me know if this reproduction is complete/helpful or I will supplement it with whatever you need.

princeV commented 2 years ago

@SeraVault I had the same issue and it was just that i missed to update the supabase auth settings with the github infos: github: image

then update supabase under github enabled: image

this helped me to get rid of the 404...

nberlette commented 2 years ago

I was going to open a new issue, but I believe I've encountered this issue on the auth flow of the demo site itself. Check out this 5 second recording I've made below:

https://user-images.githubusercontent.com/11234104/171913428-29c5cd79-109d-4610-86f6-07ad6f56f51f.mov

larbish commented 2 years ago

@nberlette concerning the demo, I tried something in local and have updated the auth redirect URL of the supabase dashboard to localhost:3000. I simply forgot to set it back to the good URL afterward. Sorry for that, it should be fixed.

nddr commented 2 years ago

I've been having this same issue using Discord and Google auth. It was working perfectly for a while, and a month or so ago, it just stopped working and I receive these errors in the console.

POST http://localhost:3000/api/_supabase/session 404 (Not Found)

Uncaught (in promise) FetchError: 404 Not Found (/api/_supabase/session)
    at async Object.callback (supabase.client.mjs:22:7)

Last night I reset Discord creds to test, but still same issue :/

offeronhomes commented 2 years ago

I was experiencing the same issue and when i went back to 0.1.10 is started working again. huh. Will provide my repo soon.

nddr commented 2 years ago

Reverting @nuxtjs/supabase to 0.1.10 has worked for me

larbish commented 2 years ago

Are you still facing this issue with v0.2.0 ?

nddr commented 2 years ago

@larbish I am not. It is working well.

peterkimzz commented 1 year ago

Hi, @larbish

I got same issue in only production mode, not localhost.

const { data, error } = await supabase.auth.verifyOtp({
    type: "magiclink",
    email: form.email,
    token: form.token,
  });

console.log(data)

The console.log shows an user's data successfully, but failed to request /api/_supabase/session only in production. So SupabaseUser() has noting.

Here is my info,


image
atinux commented 1 year ago

@peterkimzz what command do you use to deploy your Nuxt app?

peterkimzz commented 1 year ago

@Atinux I didn't override any option of the Nuxt project configuration and Vercel build option. I created a project by Vercel guideline.

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev -p 3003",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare",
    "test": "nuxt typecheck"
  },
  "devDependencies": {
    "@nuxtjs/supabase": "0.3.0",
    "@nuxtjs/tailwindcss": "6.1.3",
    "@tailwindcss/forms": "0.5.3",
    "husky": "8.0.2",
    "nuxt": "3.0.0"
  },
  "dependencies": {
    "@heroicons/vue": "2.0.13",
    "@supabase/supabase-js": "2.1.1"
  }
}
image
atinux commented 1 year ago

Try to overwrite and set "npm run build"

mmartinsolisdev commented 1 year ago

I have the same error when deploying to production on Netlify or Cloudflare Pages. Everything works fine locally. I have tried npm run build and npm run generate commands and they both have the same result when my app is deployed and I try to logIn with Google.

Netlify error POST https://admirable-baklava-3c95f7.netlify.app/api/_supabase/session 404

Cloudflare error

POST https://burpeefly.pages.dev/api/_supabase/session 405
Uncaught (in promise) FetchError: 405  (/api/_supabase/session)
    at async Object.callback (entry.af57154f.js:5:118018)

My package.json

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "@nuxtjs/supabase": "^0.3.0",
    "@vicons/ionicons5": "^0.12.0",
    "naive-ui": "^2.33.4",
    "nuxt": "^3.0.0"
  }
}
marc-tech commented 1 year ago

same here can it be the SITE_URL / BASE_URL ?

atinux commented 1 year ago

We don't advice to use the Supabase module with nuxt generate since it's better to have an API endpoint running too for your app.

Leverage nuxt build for Netlify instead.

marc-tech commented 1 year ago

it's a probleme with vercel, because of /api edge function proxy (i don't know yet how to resolve this issue)

fdarkaou commented 1 year ago

I still have this issue, is there any fix for this?