Reputation: 18477
I have a node.js app I am creating and I am using restify. I have setup a GET
route for some data, but I am also wanting to serve static content from my root.
GET route:
server.get({path : SURVEY_QUESTION_PATH, version : appVersion}, getLandingSurveyQuestions);
Static routes:
server.get(/\/?.*/, restify.serveStatic({
directory: 'static',
default: 'index.html'
}));
This static route is conflicting with my dynamic route: How do I serve up this static content, without conflicting with the other routes I have? I'd hate to have to setup static routes for all of the individual files in my project.
I have tried:
Upvotes: 3
Views: 615
Reputation: 18477
So far I have a hack: changing the regex to include the common static files that will be served up. This seems inefficient, but works.
server.get(/(^\/$)|(\.(html|js|css|png|jpg)$)/, restify.serveStatic({
directory: 'static',
default: 'index.html'
}));
Upvotes: 4