Home react always redirect to homepage
Reply: 1

react always redirect to homepage

Ivan Sugiarto
Ivan Sugiarto Published in 2018-01-10 15:19:15Z

First of all I'm new to react, so i'm still learning about it.

I got this problem with react if I make a hyperlink from another domain/site to react app on localhost, eg http://localhost:8089/foo/bar. it show the correct page directly but if I make a hyperlink from another domain/site to a public domain with https protocol eg https://example.com/foo/baz it always redirected to homepage page (https://example.com/)

is there anything I can do to make it go straight to https://example.com/foo/baz. I run react on nginx web server with this redirection setting it went well for php, django etc but won't run with react.

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name example.com;
    return 301 https://$server_name$request_uri;
    root /home/[path to dist folder]/web/app/dist;
    index index.html index.htm;


FYI the react app is build with webpack thanks in advance

Pmimo Reply to 2018-01-10 15:37:32Z

I things the probleme is :

"return 301 https://$server_name$request_uri;"

You should maybe replace it :

"return 301 https://$server_name/$request_uri;"
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.326044 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO