Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when use subpath in baseURL #984

Closed
nam0107 opened this issue Jan 16, 2025 · 8 comments · Fixed by #986
Closed

Problem when use subpath in baseURL #984

nam0107 opened this issue Jan 16, 2025 · 8 comments · Fixed by #986
Labels
bug A bug that needs to be resolved p4 Important Issue

Comments

@nam0107
Copy link

nam0107 commented Jan 16, 2025

Environment

[email protected]
@sidebase/[email protected]

nodejs: v20.18.1

Reproduction

I set both
AUTH_ORIGIN and baseURL = https://rpdev-gui.dev-vie.int.compax.at/aax4/api/auth

Describe the bug

After I login successful, I got wrong redirect url. I expect redirect url should be https://rpdev-gui.dev-vie.int.compax.at/aax4 but it is https://rpdev-gui.dev-vie.int.compax.at
Then I check the api get providers I got this
image
the signinUrl and callbackUrl should include /aax4 but not and I think it cause my issue

this is my config
image

Additional context

No response

Logs

No response

@nam0107 nam0107 added bug A bug that needs to be resolved pending An issue waiting for triage labels Jan 16, 2025
@phoenix-ru
Copy link
Collaborator

phoenix-ru commented Jan 16, 2025

Can you please show your directory structure in the server folder? IIRC, you need to put your api/auth/[...].ts into server/routes

upd: was able to reproduce and fix

@phoenix-ru phoenix-ru added p4 Important Issue and removed pending An issue waiting for triage labels Jan 16, 2025
@phoenix-ru
Copy link
Collaborator

@nam0107 Please, check the new version using:

npm i https://pkg.pr.new/@sidebase/nuxt-auth@986

@phoenix-ru
Copy link
Collaborator

@nam0107 You can try using the next tag which includes this fix:
https://www.npmjs.com/package/@sidebase/nuxt-auth/v/0.10.1-alpha.1?activeTab=versions

@nam0107
Copy link
Author

nam0107 commented Jan 16, 2025

@phoenix-ru thank you very much, I will try it and get back to you

@brucetony
Copy link

brucetony commented Jan 17, 2025

Upgrading to 0.10.1-alpha.1 causes a 400 error when trying to login:

{
    "url": "/api/auth/providers/signin/keycloak",
    "statusCode": 400,
    "statusMessage": "Invalid path used for auth-endpoint. Supply either one path parameter (e.g., `/api/auth/session`) or two (e.g., `/api/auth/signin/github` after the base path (in previous examples base path was: `/api/auth/`. Received `providers,signin,keycloak`",
    "message": "Invalid path used for auth-endpoint. Supply either one path parameter (e.g., `/api/auth/session`) or two (e.g., `/api/auth/signin/github` after the base path (in previous examples base path was: `/api/auth/`. Received `providers,signin,keycloak`",
    "stack": "<pre><span class=\"stack internal\">at createError (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:72:15)</span>\n<span class=\"stack internal\">at parseActionAndProvider (./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@babel+core@7._bk7q537wv7a5sizeybidstii2y/node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.js:156:11)</span>\n<span class=\"stack internal\">at createRequestForAuthjs (./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@babel+core@7._bk7q537wv7a5sizeybidstii2y/node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.js:120:34)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@babel+core@7._bk7q537wv7a5sizeybidstii2y/node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.js:44:31)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1889:24)</span>\n<span class=\"stack internal\">at Object.handler (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2202:34)</span>\n<span class=\"stack internal\">at ./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:1963:31</span>\n<span class=\"stack internal\">at process.processTicksAndRejections (node:internal/process/task_queues:105:5)</span>\n<span class=\"stack internal\">at async Object.callAsync (./node_modules/.pnpm/[email protected]/node_modules/unctx/dist/index.mjs:72:16)</span>\n<span class=\"stack internal\">at async Server.toNodeHandle (./node_modules/.pnpm/[email protected]/node_modules/h3/dist/index.mjs:2255:7)</span></pre>"
}

@brucetony
Copy link

Getting a weird redirect with the signIn() method:

No match found for location with path "/api/auth/signin/keycloak/callback/keycloak"

Could this be from changing from .origin to .href in the handler?

@nam0107
Copy link
Author

nam0107 commented Jan 20, 2025

@phoenix-ru after I upgrade version of Nuxt-auth to 0.10.1-alpha.1
this api send wrong redirect_uri, the correct should be domain/api/auth/callback/auth-server-v2 not domain/api/auth/signin/auth-server-v2/callback/auth-server-v2

Image

Image

my config here
env: AUTH_ORIGIN=http://localhost:3883/api/auth

Image

@phoenix-ru
Copy link
Collaborator

@nam0107 Thanks for reporting, really appreciate this early testing! Possibly same issue as #990, let's move there to keep this issue closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug that needs to be resolved p4 Important Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants