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

Support different application baseURL than '/' #60

Open
patrsc opened this issue Sep 28, 2024 · 8 comments
Open

Support different application baseURL than '/' #60

patrsc opened this issue Sep 28, 2024 · 8 comments
Labels

Comments

@patrsc
Copy link

patrsc commented Sep 28, 2024

Nuxt applications allow to be hosted on a different subpath than '/' by setting the app.baseURL configuration parameter. This can also be overridden at runtime by setting the NUXT_APP_BASE_URL environment variable.

Can this setting (both app.baseURL and runtime NUXT_APP_BASE_URL) be respected by nuxt-oidc-auth? Currently, I get always redirected to /auth/login, even when providing a different prefix, e.g. NUXT_APP_BASE_URL=/prefix/. I believe it would be convenient to automatically prefix all relevant configuration parameters with the App baseURL, for example: If i set oidc.providers.[provider].callbackRedirectUrl to "/bye", then actually I should be redirected to "/prefix/bye" if NUXT_APP_BASE_URL=/prefix/ was set.

@schinois
Copy link

Hello,

Same wish for me :) i saw it today and i need it too on my side. @patrsc do you have any workarround ?

@patrsc
Copy link
Author

patrsc commented Oct 1, 2024

Same wish for me :) i saw it today and i need it too on my side. @patrsc do you have any workarround ?

No, I didn't try any workarounds yet.

@itpropro itpropro added the enhancement New feature or request label Oct 3, 2024
@itpropro
Copy link
Owner

itpropro commented Oct 3, 2024

It didn't make it to 1.0.0-beta.1, but it is in the works for one of the betas before 1.0.0!

@itpropro
Copy link
Owner

itpropro commented Jan 5, 2025

I just tried to add a prefix in the nuxt config and everything works as expected including the redirections, as the prefix redirection of nuxt always take place before the route rules go into effect.
Is there anything specific that is not working for you @patrsc ?

@freddiv
Copy link

freddiv commented Jan 24, 2025

I just updated to 1.0.0-beta.5 and then used an alternate baseURL that works great on a dev build but when doing a build / start to test a production build it fails with a 404 can't find /auth/login

If I prepend the baseURL value to the auth/login page that returned the 404, I get the correct login page but when I try to login it fails because it cannot find the auth/oidc/callback with another 404

These paths use the correct prefix in a dev build and it functions perfectly Is there any trick to get this to work on production builds?

@itpropro
Copy link
Owner

I just updated to 1.0.0-beta.5 and then used an alternate baseURL that works great on a dev build but when doing a build / start to test a production build it fails with a 404 can't find /auth/login

If I prepend the baseURL value to the auth/login page that returned the 404, I get the correct login page but when I try to login it fails because it cannot find the auth/oidc/callback with another 404

These paths use the correct prefix in a dev build and it functions perfectly Is there any trick to get this to work on production builds?

That's very good input! I will include some tests for baseUrl changes, as the e2e tests run on a production build. It should be possible to figure out, why it doesn't work there.

@freddiv
Copy link

freddiv commented Jan 26, 2025

That's very good input! I will include some tests for baseUrl changes, as the e2e tests run on a production build. It should be possible to figure out, why it doesn't work there.

Thanks! I look forward to your findings on this. If it works on a production build for you maybe there is something I am missing. If not hopefully my input helps you get the issue resolved.

@freddiv
Copy link

freddiv commented Jan 28, 2025

That's very good input! I will include some tests for baseUrl changes, as the e2e tests run on a production build. It should be possible to figure out, why it doesn't work there.

I'm wondering if there is any movement on this. We are getting ready to go live on the application and it is going to require a baseUrl prefix on the app.

I was reading the docs here

The middleware automatically redirects all requests to `/auth/login` if the user is not logged in. You can disable this behavior by setting `redirect` to `false` in the `middleware` configuration.

"This module can automatically add a global middleware to your Nuxt server. You can enable it by setting globalMiddlewareEnabled under the middleware section of the config.
The middleware automatically redirects all requests to /auth/login if the user is not logged in. You can disable this behavior by setting redirect to false in the middleware configuration."

I tried to use the redirect set to false but it doesn't seem to do anything as far as stopping the redirects from happening before the and putting up a 404 page (not our 404 page) and although the url path shows up correctly on the location bar the view is still on a 404 page. If I put the cursor in the location bar and hit enter it shows the correct page view.

I tried to set globalMiddlewareEnabled: false but that also has ne effect on the redirects that happen without the app baseUrl path being rendered either.

Really at a loss as to how to make this work for us with the baseURL set in production builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants