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

[legacy-framework] use decodeURIComponent for router.query.next during page authentication redirect #2114

Merged
merged 4 commits into from
Mar 17, 2021
Merged

[legacy-framework] use decodeURIComponent for router.query.next during page authentication redirect #2114

merged 4 commits into from
Mar 17, 2021

Conversation

remjx
Copy link

@remjx remjx commented Mar 14, 2021

I ran into an issue where my Page.authenticate = { redirectTo: "/login" } was not working as expected. The initial page was http://localhost:3000/page-i-refreshed and the redirect URL was http://localhost:3000/login?next=%2Fpage-i-refreshed (this is OK so far). But after I logged in, the URL changed to http://localhost:3000/%2Fpage-i-refreshed instead of back to http://localhost:3000/page-i-refreshed which generated a 404.

What are the changes and their implications?

Use decodeURIComponent on the router.query.next path before router.push

Update blitz generate template
Update default login example

Checklist

  • Changes covered by tests (tests added if needed)
  • PR submitted to blitzjs.com for any user facing changes (N/A)

@remjx remjx changed the title Update examples: use decodeURIComponent for router.query.next during page authentication redirect use decodeURIComponent for router.query.next during page authentication redirect Mar 14, 2021
@remjx
Copy link
Author

remjx commented Mar 14, 2021

I'm having trouble getting the tests to run, I made a post in help channel in Discord https://discord.com/channels/802917734999523368/814628067788062750/820540099795091468

@flybayer
Copy link
Member

The tests are still failing with a type error. Probably you need to do decodeURIComponent(router.query.next!) or cast it like it was.

Make sure the tests pass. You can run yarn jest from examples/auth/ to run these tests.

@flybayer
Copy link
Member

Yay, thank you!!

@flybayer flybayer merged commit 9616836 into blitz-js:canary Mar 17, 2021
@blitzjs-bot
Copy link
Contributor

Added @remjx contributions for code

@itsdillon itsdillon changed the title use decodeURIComponent for router.query.next during page authentication redirect [legacy-framework] use decodeURIComponent for router.query.next during page authentication redirect Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants