supabase icon indicating copy to clipboard operation
supabase copied to clipboard

404 error on API session route

Open SeraVault opened this issue 2 years ago • 12 comments

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

SeraVault avatar May 21 '22 23:05 SeraVault

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

larbish avatar May 23 '22 08:05 larbish

How do you deploy your project @SeraVault ?

Atinux avatar May 23 '22 09:05 Atinux

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

SeraVault avatar May 24 '22 03:05 SeraVault

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.

daanvangeloven avatar May 27 '22 09:05 daanvangeloven

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

larbish avatar May 30 '22 09:05 larbish

@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.

daanvangeloven avatar Jun 01 '22 11:06 daanvangeloven

@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...

princeV avatar Jun 03 '22 16:06 princeV

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

nberlette avatar Jun 03 '22 17:06 nberlette

@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.

larbish avatar Jun 03 '22 19:06 larbish

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 :/

nddr avatar Jun 29 '22 16:06 nddr

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.

offeronhomes avatar Jun 29 '22 20:06 offeronhomes

Reverting @nuxtjs/supabase to 0.1.10 has worked for me

nddr avatar Jul 04 '22 04:07 nddr

Are you still facing this issue with v0.2.0 ?

larbish avatar Oct 22 '22 10:10 larbish

@larbish I am not. It is working well.

nddr avatar Oct 22 '22 12:10 nddr

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,


  • Operating System: Darwin
  • Node Version: v16.18.0
  • Nuxt Version: 3.0.0
  • Nitro Version: 1.0.0
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: runtimeConfig, modules, tailwindcss, supabase
  • Runtime Modules: @nuxtjs/[email protected], @nuxtjs/[email protected]
  • Build Modules: -

image

peterkimzz avatar Dec 06 '22 11:12 peterkimzz

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

Atinux avatar Dec 06 '22 13:12 Atinux

@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

peterkimzz avatar Dec 07 '22 02:12 peterkimzz

Try to overwrite and set "npm run build"

Atinux avatar Dec 07 '22 09:12 Atinux

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"
  }
}

mmartinsolisdev avatar Dec 07 '22 21:12 mmartinsolisdev

same here can it be the SITE_URL / BASE_URL ?

marc-tech avatar Feb 05 '23 01:02 marc-tech

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.

Atinux avatar Feb 07 '23 12:02 Atinux

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

marc-tech avatar Mar 27 '23 00:03 marc-tech

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

fdarkaou avatar Jul 14 '23 11:07 fdarkaou