Netlify "page not found" when sharing React-Router-Dom based links

Not seeing where you create your _redirects, @Santoro? Could you tell me how you’re making the one that is described here?

I created a _redirects file in public folder with this content below:

SOLVED FOR ME! THANKS SO MUCH

Redirects from what the browser requests to what we serve

/* /index.html 200

Hi, @naothomachida. Thanks for confirming the solution which worked for you!

(This is very helpful for others searching the community site and our support team appreciates this update as well.) :+1:

Signed up just to Thank You.

I was using prerendering feature and having this no route found issue. Your solution worked flawlessly.

Thanks Man.

1 Like

I’ve got that kind of problem too, I’ve been using react-router-dom and on localhost links worked fine, until I’ve pushed my repo to github and deployed it to netlify, what I did was just adding a _redirect file inside public/ folder and put /* /index.html 200 inside of that file, and voilà my links a now working on Netlify.
I’ve created a community account just to thank you.
Love the Netlify product <3

glad it is working for you! thanks for the kind words :slight_smile:

Create the _redirects file worked for me too! Thx :blush:

2 Likes

Thanks very much Mr. @jaylowe1 and @luke, it works, just to recap:

  1. Add _redirects file in your public folder
  2. Write down inside file:

/* /index.html 200

In my case I have no issues with my builder adding .txt extension, I’m using CRA(Create React App).

You guys Rock!

4 Likes

this worked like a charm, thank you!

1 Like

Hi there,

I think I have a similar issue, though adding the _redirects file within the public directory has not solved it.

Whenever I try and route to a page through a direct (nested) URL , such as ‘JVC Parry’, it fails to load a page and gives the error

Uncaught SyntaxError: Unexpected token '<' main.e3eaf229.chunk.js:1

However when I navigate the deployed version through links, everything loads fine. I also don’t get this error when I’m running the app locally, which I guess means it must be something to do with deployment?

I’ve trawled through all the other posts I can find with this error, and also things to do with Netlify/CRA deployments.

My code is on github here: GitHub - NatClamp/jvcparry

Deployed version is here:
https://jvcparry.com/ and if you go to JVC Parry you’ll see the error I’m getting.
This is the netlify page: Netlify App

Can anyone shed any light on this? Thanks in advance

1 Like

hi there! can you first confirm that all of your redirects are being processed?

I’m experiencing the same problem as @ichbinclamp , and my one redirect rule /* /index.html 200 is indeed being processed fine. Any thoughts?

Edit: it seems that it’s trying to retrieve the /static/ js / CSS files at the end of the full path, instead of at the root of the site? Related to this post: Create-react-app netlify.toml redirects rule redirects all static js files to index.html

Hi, @brianjychan. The redirect rule you posted wouldn’t make that change.

The issue has to do with how the assets are referenced in the HTML. For example:

href="/manifest.json"

That will always load manifest.json from the site root.

However, if the reference one of these below instead:

href="manifest.json"

or:

href="./manifest.json"

Then the URL used for the HTTP request will be relative to the current path.

Would you please send us a link to the site? If so, we will be happy to see if that is the issue or not.

I found the issue! In my package.json, I had marked homepage as "./", so changing it to "/" removed the error. Thanks @luke your point tipped me off to it.

1 Like

Thanks! This works just fine

1 Like

Thank you for this. This worked like a charm.

2 Likes

Amazing! This worked for me as well when I was trying to redirect via react-select or directly typing a path into my browser :+1:

Thank you so much!!

With this answer, I solve my problem in 3 min.

Keep going!

Regards

Jonas

1 Like

Glad this got you on the right path! Happy building :netliconfetti:

3 posts were split to a new topic: Eleventy to redirect to an Obsidian Publish