Have tried everything but redirects doesn't work

I have a _redirects file in my public folder where my index.html file is. In the _redirects file i have this:

/* /index.html 200

The client side routing works when i run my react app locally however when i deploy it using netlify drop the client side routing doesn’t work. I think it is working slightly as I don’t get a 404 but the page is blank when I try an access a URL without navigating there through the website. In the console I also get this message

Uncaught SyntaxError: Unexpected token ‘<’

I think this is what is causing my page not to render but can’t work out why this is coming about?
Any help much appreciated thank you!

@layla93k What you’ve described indicates to me that the rewrite in your _redirects file is working.

Your issue is probably related to your asset paths.

What’s the link to your site?

Hi thank you for your response!

It is:

thedidsburywardrobe.netlify.ap

Some of the paths are

/api/clothing/:category
/api/items/:clothing_id

Category can be one of dresses, tops, jumpsuits, accessories etc

Clothingid is a number

@layla93k My previous guess was correct.

The issue is your asset paths.

If you were to go directly to this URL:
https://thedidsburywardrobe.netlify.app/api/items/8

The assets look like they exist:

But the actual contents are those of your /index.html file:

This is because the files don’t exist at those locations, and the rewrite rule is working.

The rewrite rule says “for any path that doesn’t have a file, return the contents of /index.html”.

You can see the page is trying to load:
https://thedidsburywardrobe.netlify.app/api/items/static/js/main.c42dee9b.js

But we know that particular file is actually here:
https://thedidsburywardrobe.netlify.app/static/js/main.c42dee9b.js

It’s loading the incorrect location because the asset paths have been specified with Relative URLs.

You’ll notice they all begin with ./ or ../ etc.

You should specify them as Root Relative URLs, so they should begin with /

I’m not sure what you’re working with, as you’ve not said, but if you’re using Vite you may have made precisely the same mistake as this other user:

Who had accidentally set the base in their vite.config.js to ./

Oh, and regarding your index.js file, that one simply doesn’t seem to exist at all.
To confirm that you should run your build command locally, and then check the files it outputs.

Thank you! This worked!