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

[next-auth][error][CLIENT_FETCH_ERROR], *DESPITE* Environmental Variables Being Present #8174

Closed
machineghost opened this issue Jul 29, 2023 · 5 comments
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@machineghost
Copy link

machineghost commented Jul 29, 2023

Environment

System:
OS: Linux 5.15 Linux Mint 21.1 (Vera)
CPU: (8) x64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
Memory: 8.78 GB / 23.38 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.3.0 - /usr/local/bin/node
npm: 9.6.7 - /usr/local/bin/npm
Browsers:
Chrome: 114.0.5735.198

Reproduction URL

None; if I can't get the starting instructions to even work, I certainly won't deploy it live :)

Describe the issue

There seems to be several variations (see #3560), but the core idea is that when you get the CLIENT_FETCH_ERROR:

client.js:1 [next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error Unexpected token '<', "<!DOCTYPE "... is not valid JSON {error: {…}, url: '/api/auth/session', message: Unexpected token '<', "<!DOCTYPE "... is not valid JSON}

it directs you to a URL telling you to set an environmental variable ... but that variable isn't the issue.

How to reproduce

I was just following the tutorial and I ran into it. Presumably, any number of things could go wrong with setting up the route, including forgetting to set it up entirely.

Expected behavior

Instead of getting an error message with a URL that directs the user to set the environmental variable, the URL should explain that the route handler is not working, and suggest several things to check for what could be making it not work.

@machineghost machineghost added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Jul 29, 2023
@marquez138
Copy link

getting a similar error with the fauna adapter

@balazsorban44 balazsorban44 added the incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. label Jul 31, 2023
@github-actions
Copy link

We cannot recreate the issue with the provided information. Please add a reproduction in order for us to be able to investigate.

Why was this issue marked with the incomplete label?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We prefer a link to a public GitHub repository (template), but you can also use a tool like CodeSandbox or StackBlitz.

To make sure the issue is resolved as quickly as possible, please make sure that the reproduction is as minimal as possible. This means that you should remove unnecessary code, files, and dependencies that do not contribute to the issue.

Please test your reproduction against the latest version of NextAuth.js (next-auth@latest) to make sure your issue has not already been fixed.

I added a link, why was it still marked?

Ensure the link is pointing to a codebase that is accessible (e.g. not a private repository). "example.com", "n/a", "will add later", etc. are not acceptable links -- we need to see a public codebase. See the above section for accepted links.

What happens if I don't provide a sufficient minimal reproduction?

Issues with the incomplete label that receives no meaningful activity (e.g. new comments with a reproduction link) are closed after 7 days.

If your issue has not been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction. (It's less likely that we check back on already closed issues.)

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. Furthermore, you can upvote the issue using the 👍 reaction on the topmost comment (please do not comment "I have the same issue" without repro steps). Then, we can sort issues by votes to prioritize.

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

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

However, sometimes we might miss one or two. 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

@machineghost
Copy link
Author

machineghost commented Jul 31, 2023

Repro is very simple: follow the basic starting instructions on your website, get anything wrong with the server-side route (eg. forget to make the [...nextauth]/route.js file, put it in the wrong place, have a typo in it, etc.), and get the error:

client.js:1 [next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error Unexpected token '<', "<!DOCTYPE "... is not valid JSON {error: {…}, url: '/api/auth/session', message: Unexpected token '<', "<!DOCTYPE "... is not valid JSON}

That error links to https://next-auth.js.org/errors#client_fetch_error, which falsely suggests that the problem is an environmental variable ... when the actual problem has nothing to do with any environment variable (the problem is the route setup).

balazsorban44 added a commit that referenced this issue Aug 18, 2023
@balazsorban44
Copy link
Member

Clarified in the docs: dcb11da

@machineghost
Copy link
Author

While the new language is a lot better, it still doesn't clarify that the fundamental problem is that the /api/auth/session endpoint doesn't exist :(

Why not just explain that in the message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incomplete Insufficient reproduction. Without more info, we won't take further actions/provide help. triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

3 participants