2

My default router is :

app.get('/', function (req, res) {
    console.log("default");
    res.send("ok");
});

If I don't have a index.html in my static directory, the log and send will output as will,

but when I add index.html, the router will direct jump to the page, then I change the name index to another name, it doesn't jump again.

Why this happen? How can I change this setting things?

1
  • Can you give a bit more code about how you have set up your middleware? Commented Jan 4, 2013 at 3:52

1 Answer 1

5

It's your middleware order and configuration that causes this behavior. You presumably are using the static middleware and by default that happens before the app.router middleware. The solution is either:

  • configure your static middleware to only serve exact file matches without any automatic index.html behavior
  • put app.user(app.router); before your static middleware
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.