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

Router push to other domain with same prefix #40677

Open
1 task done
ReinoutStevens opened this issue Sep 19, 2022 · 1 comment
Open
1 task done

Router push to other domain with same prefix #40677

ReinoutStevens opened this issue Sep 19, 2022 · 1 comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.

Comments

@ReinoutStevens
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

/bin/sh: 1: yarn: not found
/bin/sh: 1: pnpm: not found

Operating System:
  Platform: linux
  Arch: x64
  Version: #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022
Binaries:
  Node: 16.14.2
  npm: 8.5.0
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.1.0
  react: 17.0.2
  react-dom: 17.0.2

warn - Latest canary version not detected, detected: "12.1.0", newest: "12.3.1-canary.3".
Please try the latest canary version (npm install next@canary) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

NextJS router wrongly uses startsWith to see whether a link is running on the same origin or not. This fails when your site is running on example.com, but you push to example.com.br for a Portugese version of your site.

Expected Behavior

Site is running on example.com, example.fr and example.com.br

Example.com calls router.push('https://example.fr'), which works just fine.
Example.com calls router.push('https://example.com.br/portugese-page'), which opens example.com/.br/portugese-page instead.

Link to reproduction

https://github.com/ReinoutStevens/nextjs-router

To Reproduce

The minimal example illustrates the problem, but does not reproduce it on localhost as the port number is also taken into account ( and so you cant have localhost:3000 and localhost.com:3000 ).

@ReinoutStevens ReinoutStevens added the bug Issue was opened via the bug report template. label Sep 19, 2022
@ReinoutStevens ReinoutStevens changed the title Router push Router push to other domain with same prefix Sep 19, 2022
@vercel-release-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@vercel-release-bot vercel-release-bot added the stale The issue has not seen recent activity. label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. stale The issue has not seen recent activity.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants