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

[Bug]: I can't navigate to the /path directly #11321

Closed
andresogando opened this issue Mar 3, 2024 · 2 comments
Closed

[Bug]: I can't navigate to the /path directly #11321

andresogando opened this issue Mar 3, 2024 · 2 comments
Labels

Comments

@andresogando
Copy link

What version of React Router are you using?

6.22.2

Steps to Reproduce

  1. Serve the app nx serve app
  2. Try to navigate directly to a path. Eg: http://localhost:4200/protected instead of travelling through the main path / using <Link to='protected' >

Expected Behavior

Expected behaviour to display the actual view of the page in the path visited.

Actual Behavior

Response:

Screenshot 2024-03-03 at 2 04 49 PM

@andresogando
Copy link
Author

andresogando commented Mar 3, 2024

More Context:

I changed the bundler to use Vite ~5.0.0 and it works seamlessly:

 "@nx/vite": "18.0.5",
 "@vitejs/plugin-react": "^4.2.0",
 "vite": "~5.0.0",

but originally I'm using webpack

"webpack-cli": "^5.1.4"
"@svgr/webpack": "^8.0.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@nx/webpack": "^18.0.5",

@brophdawg11
Copy link
Contributor

Your webpack server will need to be configured to serve your index.html for "any" route, not just /. This is commonly referred to as "SPA Fallback" and is handled by Vite automatically (https://main.vitejs.dev/config/shared-options.html#apptype).

From a quick search, you probably want to check out this config in webpack: https://webpack.js.org/configuration/dev-server/#devserverhistoryapifallback

@brophdawg11 brophdawg11 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants