Allow certain routes to bypass the router when using createBrowserRouter #10870
Replies: 2 comments
-
This sounds like a server setup issue - you are in control of what routes should return // Send /api/* through to your API rotues
app.get('/api', handleApiRequest);
// Render everything else via React Router and the index.html page
app.get('*', handleAppRequest); |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi @JohnnyRacer did you find a workaround to this? I am facing the exact issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am trying to access my API routes which are proxied to share the same URL name as the React router page. When I make requests to the API path, it will return the React page's
index.html
, which blocks any potential API requests from going through. However, there doesn't seem to a way to achieve this properly.Creating the router
I tried to add a path for /api but it just seems to render a blank page and still block the API request when I attempt to fetch data. I've tried to using a different root domain as a way around this but dealing with CORS is a pain that I would like to avoid. With the
BrowserRouter
where I added in routes via the<Route>
element, this was not an issue as by default it would go to local route first instead of being redirected automatically. Is there a way I can get this to work?Beta Was this translation helpful? Give feedback.
All reactions