okta / samples-js-react

React Auth SDK sample
Other
174 stars 257 forks source link

Everything works on localhost, but not on Vercel #309

Closed vaporpin closed 8 months ago

vaporpin commented 8 months ago

I managed to get the application working with Okta. It ran perfectly fine on localhost (both login and logout were successful). As HTTPS is necessary since PKCE is used, I tried to deploy the application to Vercel to speed up my deployment.

One edit I have to do is changing the base to just "/", so that issues like this can be resolved GET https://xxx/okta-hosted-login/assets/index.aa0306c6.js net::ERR_ABORTED 404 (Not Found) xxx.app/:13 GET https://xxx/okta-hosted-login/assets/index.0145397a.css net::ERR_ABORTED 404 (Not Found)

return { // base: includeSampleBaseName ? '/okta-hosted-login/' : '/', base: '/', plugins: [react()], define: { 'process.env': env },

The build and deploy was successful but after i login to the okta default login page, i got another error

GET https://xxxx-xxx.vercel.app/login/callback?code=xxx&state=xxx 404 (Not Found)

I have already added "https://xxxx-xxx.vercel.app/login/callback" into okta sign-in redirect uris

Can anyone advise?

Thank you.

vaporpin commented 8 months ago

solved the error. for anyone who is interested in deploying to vercel for this repo, you should include a vercel.json file with this content. everything works now

{ "rewrites": [{ "source": "/(.*)", "destination": "/" }] }