nuxt-auth
nuxt-auth copied to clipboard
redirect_uri is always http://localhost:3000
Environment
Working directory: /home/bertilipsen/odin-ui 4:34:56 PM Nuxt project info: 4:34:56 PM
- Operating System: Linux
- Node Version: v18.18.0
- Nuxt Version: 3.10.1
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: [email protected]
- Builder: -
- User Config: devtools, modules, runtimeConfig, primevue, tailwindcss, css, device, auth, googleFonts
- Runtime Modules: @nuxtjs/[email protected], [email protected], @vueuse/[email protected], @nuxtjs/[email protected], @sidebase/[email protected], [email protected], @nuxtjs/[email protected], @pinia/[email protected]
- Build Modules: -
👉 Report an issue: https://github.com/nuxt/nuxt/issues/new 4:34:56 PM
👉 Suggest an improvement: https://github.com/nuxt/nuxt/discussions/new
👉 Read documentation: https://nuxt.com
Reproduction
At the moment, I am unsure how to provide a reproducible repo.
Describe the bug
No matter what I do, I can't seem to get another callback URL other than the default localhost:3000 one. I have tried with various configs, but right now, I simply use:
auth: {
globalAppMiddleware: true,
},
I set the AUTH_ORIGIN to my website in .env. I have /login page, where I simply redirect immediately, like so:
//pages/login.vue
<template></template>
<script setup lang="ts">
definePageMeta({
auth: {
unauthenticatedOnly: true,
navigateAuthenticatedTo: "/",
},
layout: "blank",
});
const { signIn } = useAuth();
signIn("auth0");
</script>
This is my handler:
//server/api/auth/[...].ts
import { NuxtAuthHandler } from "#auth";
import Auth0Provider from "next-auth/providers/auth0";
const runtimeConfig = useRuntimeConfig();
export default NuxtAuthHandler({
secret: runtimeConfig.auth.secret,
pages: {
signIn: "/login",
},
providers: [
// @ts-expect-error
Auth0Provider.default({
clientId: runtimeConfig.auth0.clientId,
clientSecret: runtimeConfig.auth0.clientSecret,
issuer: runtimeConfig.auth0.issuer,
audience: runtimeConfig.auth0.audience,
idToken: true,
authorization: {
params: {
audience: encodeURI(runtimeConfig.auth0.audience),
},
},
}),
],
});
Additional context
No response
Logs
No response
I'm seeing similar issues on any other provider. As a matter of fact, same behaviour even when trying out the https://github.com/sidebase/nuxt-auth-example repo.
I am encountering the same problem, I found a fix for it by defining the NEXTAUTH_URL
in my .env file, problem with this is that it sets the cookie to Secure
, and that will result in the cookie not getting set.
It is possible to disable Secure Cookies using the NuxtAuthHandler like this:
export default NuxtAuthHandler({
// ...
useSecureCookies: false,
// ...
})
Also running into this issue unfortunately. Tried setting the callbackUrl in the signIn method and the baseURL in the auth prop of the nuxt config as well as the devServer prop but it just stubbornly defaults to localhost:3000. NEXTAUTH_URL "fixes" that of course but I don't feel like that's an elegant or modular approach unfortunately
Yeah, this is 100% not elegant or the correct way of doing this, sadly this project only has @zoey-kaiser working on it in her free time, so its slowly falling apart. No hate to you zoey but this project has seen better times, you are doing a great job!
Yeah, this is 100% not elegant or the correct way of doing this, sadly this project only has @zoey-kaiser working on it in her free time, so its slowly falling apart.
I completely agree! We have recently introduced a new developer to the project to help sort out some of these issues! As he is currently still getting into the project it may take another week for regular updates and more activity to come 🤗
No hate to you zoey but this project has seen better times, you are doing a great job!
Thank you for the compliment! I hope it will become better soon. Next week, I will dedicate a good amount of time, to sorting through every issue, doing some triage and prioritizing them based on importance.
@zoey-kaiser thanks for the work you do here, it's great to have multiple options for auth!
Any news about that topic? i have the same issue but can not circumvent it by using NEXTAUTH_URL because in my deployment process all the env variables get mandatorily prefixed with (e.g) 'BLA_'. so it will result in BLA_NEXTAUTH_URL