Closed KoenCa closed 1 year ago
another problem with baseUrl:
if app.baseURL set in nuxt.config.ts, nuxt-auth doesn't work.
if you set app.baseURL to "/mysite/" and then set nuxt-auth basePath to /mysite/api/auth, the login links are still using old URLs to /api/auth/.
Hey @KoenCa 👋
I tested it out, and it works as expected.
I was only able to reproduce this error when I incorrectly setup the auth handler. The setup of this handler is described here: https://sidebase.io/nuxt-auth/configuration/nuxt-auth-handler
When I change:
basePath: '/api-front/auth'
in nuxt.config.ts
/routes/api-front/auth/[...].ts
I get an infinite redirect (which at some point would lead to the HTTP 431 error you reported @KoenCa. This happens because when you do not add the route/...
handler as described in step (2) above nuxt will interpret /api-front/*
requests as reuqests to a frontend page. These are protected by the global middleware, so it starts redirecting. But the redirect goes to /api-front/*
again, so it's yet another "regular" page so yet another redirect -> rinse and repeat.
For this reason I have a strong suspicion that you did not correctly add the auth handler.
Hey @kvanska 👋
I think this one is an existging, separate problem from the one that @KoenCa reported. Can you please open a new issue for this?
Hey @BracketJohn ,
You're right, I made a mistake. I changed the basePath
and renamed the api
folder to api-front
, but I should have made that folder in a routes
folder. At the time I didn't understand that api
is a default Nuxt folder and that you need to put 'custom' routes (that don't start with api
) in a separate routes
folder. So now when I put it in /routes/api-front/auth/[...].ts
, it works!
Thanks for the explanation! I shall close this issue.
Sure thing - glad that you figured it out (:
Environment
Nuxi 3.1.2
Darwin
v16.15.1
3.1.2
2.1.1
npm@8.11.0
vite
nitro
,app
,typescript
,runtimeConfig
,postcss
,schemaOrg
,modules
,css
,build
,auth
@nuxtjs/tailwindcss@6.3.0
,@vueuse/nuxt@9.12.0
,@formkit/nuxt@1.0.0-beta.14
,nuxt-schema-org@2.1.1
,@sidebase/nuxt-auth@0.4.0-alpha.5
Build Modules:
-
Reproduction
No response
Describe the bug
When changing the
basePath
the nuxt dev server breaks. For example when I change it to/api-front/auth
, I get the following error:Additional context
This happens on version
0.3.4
and0.4.0-alpha.5
.Logs
No response