Nginx location block not working for links Nginx location block not working for links nginx nginx

Nginx location block not working for links


Is the development version of your front-end also SSR? You may need to just update the links from relative paths to absolute paths, and make sure to not use the React-Router Link component. React router could be dealing with the relative path, since it sees it as a front-end route, so use an absolute path instead without the link component to send the request through Nginx.

Example

Instead of this:

<Link to='/ron-swanson-quotes'>Ron Swanson</Link>

Do this:

<a href='https://yourronswansonwebsite.com/ron-swanson-quotes'>Ron Swanson</a>

Cheers


So,

The package we are using is custom-express-server. I realized that instead of using nginx, the better option was to have an array of redirects and have a redirect in the custom express setup and a redirect for the front-end in getInitialProps.

When we did the redirect in getInitialProps, the page transitions broke so we had to hard code those in there.