When I set “/manage” as path :
router.get("/manage",function(req,res,next){
var option = {
root : path.dirname(__dirname),
}
res.sendFile("build/manage.html",option);
})
and use it in my app.js , but when I open localhost:3000/manage , I got a status “301 Moved permanently” . And I was redirected to localhost:3000/manage/
However , if I just change /manage to other path , like “/index”.
router.get("/index",function(req,res,next){
var option = {
root : path.dirname(__dirname),
}
res.sendFile("build/manage.html",option);
})
Then also open localhost:3000/index , I just got status “200 OK ” , and was NOT redirected to localhost:3000/index/
Here is the status “301 Moved permanently” response header :
HTTP/1.1 301 Moved Permanentl
X-Powered-By: Express
Content-Type: text/html; charset=UTF-8
Content-Length: 171
Content-Security-Policy: default-src ‘self’
X-Content-Type-Options: nosniff
Location: /manage/
Date: Tue, 12 Dec 2017 15:23:38 GMT
Connection: keep-alive
I think that’s very strange ,and wonder why .
Thanks for reading !
Could it be that you have a
static
middleware before that is redirecting/manage
to/manage/
since there is a directory calledmanage
?@vanesyan Thanks for taking time to reply !
I didn’t know strict parameter , and now I know it , thank you. The problem is what LinusU said , I have a
static
middleware , and have created a directory calledmanage
instatic
directory . Like this :@LinusU Thank you for taking time to reply ,too!
I have checked my code , and found I have created a directory called
manage
which is used for testing by coincidence , and forgot to delete it . After I delete it , the problem is solved . Thank you so much!