ExpressJS route regex

后端 未结 4 1190
别跟我提以往
别跟我提以往 2021-01-11 19:42

I have route:

app.get(\'/:id\', routes.action);

It works fine, but I need skip robot.txt and other (humans ....) I create rege

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 19:50

    If you want to avoid a route matching a static file that exists physically, simply put the static middleware before the call to the app.router.

    Then the static file (such as robots.txt) will be delivered and these calls will not get through to your routing.

    Problem solved ;-).

提交回复
热议问题