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

redirect_uri is always http://localhost:3000 #663

Open
bipsen opened this issue Feb 12, 2024 · 7 comments
Open

redirect_uri is always http://localhost:3000 #663

bipsen opened this issue Feb 12, 2024 · 7 comments
Labels
bug A bug that needs to be resolved p4 Important Issue

Comments

@bipsen
Copy link

bipsen commented Feb 12, 2024

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: npm@9.8.1
  • Builder: -
  • User Config: devtools, modules, runtimeConfig, primevue, tailwindcss, css, device, auth, googleFonts
  • Runtime Modules: @nuxtjs/tailwindcss@6.11.4, nuxt-primevue@0.2.2, @vueuse/nuxt@10.7.2, @nuxtjs/device@3.1.1, @sidebase/nuxt-auth@0.6.7, nuxt-icon@0.6.8, @nuxtjs/google-fonts@3.1.3, @pinia/nuxt@0.5.1
  • 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

@bipsen bipsen added the bug label Feb 12, 2024
@matthewairalo
Copy link

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.

@FrankoFM
Copy link

FrankoFM commented Feb 14, 2024

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.
image

It is possible to disable Secure Cookies using the NuxtAuthHandler like this:

export default NuxtAuthHandler({
    // ...
    useSecureCookies: false,
    // ...
})

@warflash
Copy link

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

@FrankoFM
Copy link

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!

@zoey-kaiser
Copy link
Member

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 zoey-kaiser added p4 Important Issue bug A bug that needs to be resolved and removed bug labels Feb 23, 2024
@tesla3327
Copy link
Contributor

@zoey-kaiser thanks for the work you do here, it's great to have multiple options for auth!

@tbslchnr
Copy link

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

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

No branches or pull requests

7 participants