Hi @Vaibhav
The issue here is there are two catchall/wildcard (/*) rules. If you have
/* https://my_app.herokuapp.com/api/:splat 200
/* /index.html 200
everything get routed to heroku and nothing to the app. Conversely, if you have
/* /index.html 200
/* https://my_app.herokuapp.com/api/:splat 200
everything gets routed to the app and nothing to heroku.
The best solution here is to have a specific /api rewrite e.g.
/api/* https://my_app.herokuapp.com/api/:splat 200
/* /index.html 200
so only /api/profile or /api/something route through to heroku.
Thanks @coelmay I understand what you explained but this time server is not connected to client properly.
- Taking reference through documentation I also tried,
https://client.netlify.app/* https://server.herokuapp.com/api/:splat 200 /* /index.html 200 but in this also /* /index.html 200 this rule is not working (i.e. when i refersh the page it says Cannot GET /api/something).
Can you provide another solution or any suggestion please.
You cannot have two rules for /* @Vaibhav, no matter which way they are formatted.
This rule is the same as
/* https://server.herokuapp.com/api/:splat 200
The solution is provided previously
/api/* https://my_app.herokuapp.com/api/:splat 200
/* /index.html 200
Thank you so much @coelmay 
-
It worked. I used multiple rules for different routes in _redirects.
-
The rules are like:
/user/* https://server.herokuapp.com/api/user/:splat 200,
…followed by different routes
/* /index.html 200.
Great you found a solution @Vaibhav.
If you had have used the solution I offered (i.e. /api/* ...) all calls to the back-end would go through this one redirect e.g.
/api/users, /api/login, /api/profile, and so on. That is what the * and the :splat are doing.
1 Like
Yeah, I got the logic behind the solution you offered but my client side uses http://client.netlify.app/user url to connect with server. It is not like https://client.netlify.app/api/user thats why i used multiple rules.