nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 924 forks source link

Callback error in deploying static site #1766

Open iusx opened 2 years ago

iusx commented 2 years ago

Discussed in https://github.com/nuxt-community/auth-module/discussions/1764

Originally posted by **earthrule** June 17, 2022 Hi, I'm learning nuxt-auth recently, but I'm running into a very embarrassing problem. When I'm testing github-auth, I can run it locally (via `npm run nuxt`) and have no issues with auth or fetch. After that, when I hosted it on cloudflare and deployed it using `nuxt generate --spa` \ `nuxt generate`, there was a very serious problem. I don't know why **After the authorization is successful, it still stays at** `/login ` route. And did not get the user's token information, showing `unauthorized`. Below, I will attach my environment screen recording and source code repository: ## Correct! ![Correct](https://user-images.githubusercontent.com/57232813/174143131-fa9b41c0-e850-4944-8938-0785ea694761.gif) ## Incorrect! ![Incorrect](https://user-images.githubusercontent.com/57232813/174143190-7a32fb78-b2b5-4ceb-ac41-31d48443c1cb.gif) ## Source [earthrule/github-auth-demo](https://github.com/earthrule/github-auth-demo) ## Notice I have read the submitted issues, set `mode` to spa, and wrote the official document according to the official demo (please forgive my demo style, after all, it is just a learning demo, I will debug the function when I have a chance, I will show it to you again the final result) If you have encountered such a problem or have a solution, you can tell me or pr directly, I have set the address of the github app to `http://localhost:3000/` so you can debug locally.
iusx commented 2 years ago

Please note that I have previously set the callback address to https://github-auth-demo.pages.dev/ at https://github.com/settings/developers because I uploaded the error to github for convenience. Tested so setting returns localhost: localhost:3000!!!