nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
24.1k stars 3.34k forks source link

SvelteKitAuth not working with SvelteKit's base path #8706

Closed aakash14goplani closed 11 months ago

aakash14goplani commented 11 months ago

Environment

  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
    Memory: 6.64 GB / 15.41 GB
  Binaries:
    Node: 18.17.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.7 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.5.1 - ~\AppData\Local\pnpm\pnpm.CMD
  Browsers:
    Edge: Spartan (44.22621.2283.0), Chromium (117.0.2045.36)
    Internet Explorer: 11.0.22621.1

Reproduction URL

https://github.com/aakash14goplani/SvelteKit-Auth0-NextAuth/tree/basepath and https://sveltekit-basepath.vercel.app/hello/

Describe the issue

Unable to initiate authentication flow with SvelteKitAuth while using base path.

This issue was recently claimed to be fixed via https://github.com/nextauthjs/next-auth/pull/8231 and https://github.com/nextauthjs/next-auth/issues/8230. Even after following instructions specified within those fix, authentication flow is broken.

How to reproduce

  1. Add base path in SvelteKit

    kit: {
     paths: {
       base: '/hello'
     }
    }
  2. Update SvelteKitAuth configuration object

    const config: SvelteKitAuthConfig = {
      providers: [...],
      prefix: '/hello',
      ...
    }
  3. Initiate sign-in process and observe the error :

    image

NOTE: I also tried experimenting with _NEXTAUTHURL by setting its value to -> http://localhost:4200, http://localhost:4200/hello and http://localhost:4200/hello/auth but none of them worked for me!

Dependency Versions Used:

"dependencies": {
  "@auth/core": "^0.15.1",
  "@auth/sveltekit": "^0.3.7"
},
"devDependencies": {
  "@sveltejs/adapter-vercel": "^3.0.3",
  "@sveltejs/kit": "^1.25.0",
  "svelte": "^4.2.1",
  "svelte-preprocess": "^5.0.4",
  "typescript": "^5.2.2",
  "vite": "^4.4.9"
}

Expected behavior

The authentication flow should work with the base path.

github-actions[bot] commented 11 months ago

We could not detect a valid reproduction link. Make sure to follow the bug report template carefully.

Why was this issue closed?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We need a link to a public GitHub repository. Example: (NextAuth.js example repository).

The bug template that you filled out has a section called "Reproduction URL", which is where you should provide the link to the reproduction.

What should I do?

Depending on the reason the issue was closed, you can do the following:

In general, assume that we should not go through a lengthy onboarding process at your company code only to be able to verify an issue.

My repository is private and cannot make it public

In most cases, a private repo will not be a sufficient minimal reproduction, as this codebase might contain a lot of unrelated parts that would make our investigation take longer. Please do not make it public. Instead, create a new repository using the templates above, adding the relevant code to reproduce the issue. Common things to look out for:

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps by opening a new issue.

I think my reproduction is good enough, why aren't you looking into it quickly?

We look into every issue and monitor open issues for new comments.

However, sometimes we might miss a few due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

Useful Resources