Reputation: 3
//code 1
app.use(jwt({
secret:'1'
}).unless({
path: ['/api/user/login','/api/user/sign']
}));
app.use(express.static(path.join(__dirname, 'public')));
App start on 8889 port,if i delete code 1,i can access my static resource by localhost:8889/upload/x.png,but if the code1 exsit,i cant access the static resource.please help me
Upvotes: 0
Views: 131
Reputation: 16127
The order of express middleware are importance.
Put code 1
after you set static resource:
app.use(express.static(path.join(__dirname, 'public')));
app.use(jwt({
secret:'1'
}).unless({
path: ['/api/user/login','/api/user/sign']
}));
Upvotes: 1