baseprime / grapnel

The smallest JavaScript router with named parameters, HTML5 pushState, and middleware support
http://grapnel.js.org
467 stars 40 forks source link

Working with nginx #58

Closed zacharynevin closed 7 years ago

zacharynevin commented 8 years ago

Hello,

How would I get this to work with an nginx static file server, where I don't want hashbangs between navigating. Currently it seems that doing <a href="/my/route"> triggers the page to actually navigate to that route through nginx.

I should also mention that my nginx is serving from the path /welcome:

// index.js
<base href="/welcome/">

// router.js
var router = new Grapnel({ root: '/welcome/' })

router
  .get('intro/:step', function (req, e) {
 })

// nginx.conf
location /welcome {
  try_files $uri /index.html;
}
baseprime commented 7 years ago

If you're setting up a single-page app, this answer might help you:

http://stackoverflow.com/questions/7027636/nginx-send-all-requests-to-a-single-html-page