Sunday 25 August 2019

Serving a Restify static site on nginx

I'm having some issues with this, wondering if anyone had any insights.I have a public controllerimport restify from ‘restify’; const { serveStatic } = restify.plugins; const directory = __dirname + ‘/../../../public’; const serveSite = () => serveStatic({ directory, default: ‘index.html’ }); const serveFile = file => serveStatic({ directory, file }); export default server => { server.get(‘/*’, serveSite()); server.get(‘/about’, serveFile(‘about.html’)); }; My static site (which is built using nextjs) is built and stored in /public on the server, remotely. My NGINX location directive looks like thislocation / { try_files $uri $uri/ =404; } Going to / and reloading serves the site correctly. Navigating to /about via the nav works fine, but if I refresh this route, I get a 404 page from NGINX. If I go to /about.html it works. Locally, just testing restify without NGINX involved, everything works fine so I feel it must be something to do with the server config.

Submitted August 25, 2019 at 11:00AM by moving808s

No comments:

Post a Comment