I have created a netlify.toml file and added the backed url in it, when I deploy the netlify build the home page is showign cannot GET/
[[redirects]]
from = "/*"
to = "https://ytidexpressserver.onrender.com"
status = 200
force = true
If I include the netlify url in the “from”, the page gets rendered but throws error ("AxiosError: Request failed with status code 404\n) when a request is sent
[[redirects]]
from = "/https://monumental-sunburst-e0995c.netlify.app/"
to = "https://ytidexpressserver.onrender.com"
status = 200
force = true
I have locally tested the render.com express server by including the url in proxy of my package.json file and every functionality is working properly.
So that error is simply what your express server app on render returns when a GET request is made to it at the root.
I’d imagine you’ve only configured it to handle various API requests/responses, so if you’re expecting it to return something when someone is visiting it, you would need to edit the app accordingly.
The first redirect that you show is configured to proxy EVERYTHING to your site on render.
As per 1. visiting render directly returns Cannot GET /
You would expect that visiting the root of the Netlify site would proxy to the root of the render site and thus show Cannot GET /.
The second redirect that you show has a / as the first character in the from value.
If you’re only trying to proxy certain API requests through to render, then you should adjust your redirect to provide some kind of api prefix to route the requests.
E.g.
[[redirects]]
from = "/api/*"
to = "https://ytidexpressserver.onrender.com/:splat"
status = 200
force = true
Then in your front-end react app you would ensure your API requests are adjusted to contain /api/ in their paths.
Ultimately you’re just specifying which routes are going to where.
Nothing forces you to use api as the prefix, and nothing forces you to use a prefix at all, it’s just a sane way of defining it with a single rule, which also keeps your api routes from mixing in the same space as your page routes.
If you don’t want to use a prefix you would specify each endpoint route independently.