server fall back and nested routes with react-router and url parameters

theman0123

In my react app I'm using react-router with BrowserRouter. my webpack file has

devServer.historyApiFallback: true

I have a

<Route path='/details/:parameter' />

when navigating through the app, both the fallback and the route(s) work as expected.

However, if I'm on the route that serves at /details/:parameter and I refresh, the app breaks and tells me in the console that it can't find

/details/webpack_bundle.js

however the url in the browser still contains the correct route with its parameter.

I was hoping to find an elegant solution to this. Any explanation for why it's behaving this way is appreciated.

theman0123

duplicate question: see React nested route fails to load on refresh.

I'm using HTML Webpack Plugin in webpack and this is the solution I found.

webpackConfig.output.publicPath = '/'

this loads the bundle from the root directory.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

react-router ignoring nested routes when providing url with path

分類Dev

How to Use nested routes in react router dom

分類Dev

React router nested routes. Not rendering child routes

分類Dev

React router rendering twice and URL changes by dropping all query parameters

分類Dev

React router nested not working

分類Dev

React-Router—Add/remove Routes at runtime

分類Dev

Server not responding to url with parameters

分類Dev

React show routes if set up using react-router

分類Dev

React server side rendering only specific routes

分類Dev

React Router Without Changing URL

分類Dev

break routes out of Node/Express server, but router is undefined

分類Dev

React Router v4 with babel gives error with multiple routes

分類Dev

Protect routes (scenes) using React Native Router Flux/Redux

分類Dev

React Router: How to render element on all routes, except one?

分類Dev

Preserve query parameters in react-router

分類Dev

React Router 4 - Issues Rendering Nested Link

分類Dev

Nested component in react-router is not rendering

分類Dev

angular 2 router hybrid app: url reverts back after navigate

分類Dev

react-router-dom, how to skip back button

分類Dev

react-router setRouteLeaveHook still updating URL

分類Dev

React Router URL Throws Error With Parameter

分類Dev

ReactJS - React Router not changing component but url is changing

分類Dev

Send different router in app.use() based on URL parameters

分類Dev

Parameters in URL using Angular's UI-Router, issue with .otherwise

分類Dev

Laravel - parameters in filter and routes

分類Dev

laravel routes with parameters not working

分類Dev

create comments for nested routes

分類Dev

react-router: cant display nested route in different view

分類Dev

react-routerとexpress routes.jsの違いは何ですか

Related 関連記事

  1. 1

    react-router ignoring nested routes when providing url with path

  2. 2

    How to Use nested routes in react router dom

  3. 3

    React router nested routes. Not rendering child routes

  4. 4

    React router rendering twice and URL changes by dropping all query parameters

  5. 5

    React router nested not working

  6. 6

    React-Router—Add/remove Routes at runtime

  7. 7

    Server not responding to url with parameters

  8. 8

    React show routes if set up using react-router

  9. 9

    React server side rendering only specific routes

  10. 10

    React Router Without Changing URL

  11. 11

    break routes out of Node/Express server, but router is undefined

  12. 12

    React Router v4 with babel gives error with multiple routes

  13. 13

    Protect routes (scenes) using React Native Router Flux/Redux

  14. 14

    React Router: How to render element on all routes, except one?

  15. 15

    Preserve query parameters in react-router

  16. 16

    React Router 4 - Issues Rendering Nested Link

  17. 17

    Nested component in react-router is not rendering

  18. 18

    angular 2 router hybrid app: url reverts back after navigate

  19. 19

    react-router-dom, how to skip back button

  20. 20

    react-router setRouteLeaveHook still updating URL

  21. 21

    React Router URL Throws Error With Parameter

  22. 22

    ReactJS - React Router not changing component but url is changing

  23. 23

    Send different router in app.use() based on URL parameters

  24. 24

    Parameters in URL using Angular's UI-Router, issue with .otherwise

  25. 25

    Laravel - parameters in filter and routes

  26. 26

    laravel routes with parameters not working

  27. 27

    create comments for nested routes

  28. 28

    react-router: cant display nested route in different view

  29. 29

    react-routerとexpress routes.jsの違いは何ですか

ホットタグ

アーカイブ