-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
Local Provider : baseURL not considered after deployment #368
Comments
and here is the pm2 config on my web server :
|
Any idea ? |
IT works only if the baseUrl is hardcoded like that in nuxt.config.ts :
|
I'm currently encountering the same issue in my OAuth flow. My config: auth: {
origin: process.env.AUTH_ORIGIN,
basePath: '/api/auth',
defaultProvider: 'foobar',
enableGlobalAppMiddleware: false,
}, I've checked that the This is the OAuth flow observed from the Devtools:
I have no idea why the redirect response includes a callbck URL to |
Yeah, we do deduce some stuff automatically - but in 0.6 this is a bit broken at the moment, sorry for that - the beta is not quite stable. I don't have super much time at the moment but will try to resolve this ASAP! |
@kaboume as a workaround you could try setting the |
thanks @romanzipp It's better but I'v still an issue. Now the Call Api made by SignIn meythod is https://dev.api.website.org/api/auth/auth/login in the place of https://dev.api.website.org/auth/login So Nuxt Auth added /ai/auth When I display the config :
|
having the same issue |
I had the same issue but i was able to fix it by adding: computed: {
origin: true,
fullBaseUrl: process.env.AUTH_URL,
}, to auth:{} |
Sorry, can I know where did you add this code? I mean changing from
to
|
@BracketJohn : is this issue fixed with the 0.6.0-beta.3 release ? |
i added the whole computed object inside the auth object like this:
|
Good morning, |
Hi @kaboume, We have been pretty swampped over the summer with other projects, which is why our focus sadly had to shift away from sidebase for a while. I am currently rammping up my work on the project again and have this on my list of hotfixes, to look into! |
Hello @kaboume @romanzipp 👋 I did some testing myself on version 0.6.0-beta.7. I can report the following:
Which did take my new route into account. Therefore, I conclude that in my Dev setup the According to the code, this should also be the case, as we take the given My follow up questions to properly determine your issues:
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@sidebase/nuxt-auth'],
devServer: {
port: 3001
},
auth: {
baseURL: 'http://localhost:3001/api/users',
provider: {
type: 'authjs'
},
globalAppMiddleware: {
isEnabled: true
}
}
}) |
Hi @zoey-kaiser Here is my configuration:
My frontend calls my nodeJs backend to authenticate users with a login/password. |
Hi @kaboume, Could you be so kind to tell me a bit about your deployment? Is it only a normal webserver where you then start the application or are you using Vercel, Netlify etc. |
Closed due to inactivity. If you still require more help, please comment in this issue and we can reopen it! |
This issue still persists and not even after deployment, but locally too. This is my auth: {
baseURL: process.env.NUXT_PUBLIC_API_BASE || "http://localhost:3333",
provider: {
type: "local",
endpoints: {
signIn: { path: "/login", method: "post" },
signOut: { path: "/logout", method: "post" },
signUp: { path: "/register", method: "post" },
getSession: { path: "/session", method: "get" },
},
pages: {
login: "/auth/login",
},
token: { signInResponseTokenPointer: "/accessToken" },
sessionDataType: {},
},
enableSessionRefreshPeriodically: 5000,
enableSessionRefreshOnWindowFocus: true,
globalMiddlewareOptions: {
allow404WithoutAuth: true, // Defines if the 404 page will be accessible while unauthenticated
addDefaultCallbackUrl: "/", // Where authenticated user will be redirected to by default
},
}, Using |
Found out that these lines are probably the fault here https://github.com/sidebase/nuxt-auth/blob/main/src/module.ts#L111-L113 And |
Glad I found this issue and scrolled down. I wanted to report this issue aswell. I documented this in my config like so:
So I think this might be related, although it probably is because of this line: Line 122 in 5d713aa
|
Thanks for finding this. I am not sure if this is a bug, to me it looks like an intended feature because of the default Line 111 in 5d713aa
Modifying this will be a hard breaking change for our users who already use no trailing slash at the end. We already use |
True, it is breaking change. I see that. But it should not append |
I started a new project with the 0.7.2 nuxt auth release and the problem is always here. My nuxt.config.js file :
my .gitlab-ci.yml file :
my pm2.json file :
The signIn() method calls https://[frontend]/api/auth/auth/login instead of https://backend.com/v1/auth/login I specify that locally, it works well, it is just when I deploy on the server that it does not work |
I got the same problem, after upgrading to the newest version. In the file https://github.com/sidebase/nuxt-auth/blob/main/src/runtime/composables/local/useAuth.ts#L22 it just uses: const runtimeConfig = await callWithNuxt(nuxt, useRuntimeConfig)
const config = useTypedBackendConfig(runtimeConfig, 'local')
const { path, method } = config.endpoints.signIn
const response = await _fetch<Record<string, any>>(nuxt, path, {
method,
body: credentials,
params: signInParams ?? {}
}) where |
Okay I fixed it by removing the trailing slashes in the endpoints config:
And my comment before is not valid, it considers the basePath |
No working for me, this is my config. I'm using an external backend API auth: {
provider: {
baseURL: 'https://url_backend.test/',
type: 'refresh',
endpoints: {
signIn: { path: 'login', method: 'post' },
signOut: { path: 'logout', method: 'post' },
signUp: false,
getSession: { path: 'me', method: 'get' },
refresh: { path: 'refresh', method: 'post' },
},
token: {
signInResponseTokenPointer: 'data/access_token',
cookieName: 'access_token',
type: 'Bearer',
maxAgeInSeconds: 60 * 60,
sameSiteAttribute: 'strict',
},
refreshOnlyToken: false,
refreshToken: {
signInResponseRefreshTokenPointer: 'data/access_token',
cookieName: 'access_token',
refreshRequestTokenPointer: 'access_token',
maxAgeInSeconds: 20160 * 60,
},
pages: {
login: '/login',
},
},
}, |
Doesn't work for me ! |
@kaboume, please have a look at the updated documentation, where we provided some more direct instructions for using external backends: https://auth.sidebase.io/guide/local/quick-start#using-an-external-backend Also feel free to add your suggestions to #797, where we are discussing on improving this behaviour. I think this issue is not related to any specific bugs and comes more from misconceptions brought about by outdated and wrong documentation. I will close this issue for now. Please retry your setups with the new documentation and if you experience any bugs, please open a new issue. This is primarily for housekeeping reasons and to ensure we have a better overview of issues and can track down what is going on 😊 |
ok, I finally understood where the problem was coming from. So, here is .gitlab-ci.yml file updated :
And the neaw file: setup_env_dev.sh
|
I found out the culprit, it's in url.mjs: export function joinPathToApiURL(path) {
const authStateInternal = useAuthState()._internal;
const base = path.startsWith("/") ? authStateInternal.pathname : authStateInternal.baseURL;
return joinURL(base, path);
} this was the It's super important to have a trailing slash in your baseURL but to NOT start your endpoint routes with a slash. Pretty obscure if you ask me |
Hi do you any suggest for this issue? i'm having same issue :((( |
The issue persists in version 0.9.4; I resolved it by adding a / at the end of the baseURL and removing the / from all paths. auth: {
baseURL: "https://localhost:8080/",
provider: {
type: "local",
endpoints: {
signIn: { path: "login", method: "post" },
signOut: { path: "logout", method: "post" },
},
},
}, I think this should be documented, or ideally, should handle these cases by either removing the extra slash automatically or providing a warning. |
Environment
Reproduction
No response
Describe the bug
Good morning,
I use the "Local" Provider without any problem on my laptop with an API back-end on http://localhost:8080
But when I deploy my app on my Web server, the baseUrl parameter does not seem to be taken into account.
Here is my conf:
.env (laptop)
nuxt.config.ts:
When I display the contents of the conf variable I have this:
On my Laptop :
on the web server :
However the NUXT_PUBLIC_URL_API constant is well loaded by Nuxt as shown by the public / urlApi variable of the Nuxt config
And suddenly, as the baseUrl variable is not configured, when I call signIn, the http post call is made on:
instead of :
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: