我的静态图片无法在动态路由上投放。 我在这里读了多个线程,但是没有一个解决方案起作用。
//The files in public work but those in the images folder dont
const fileStorage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, 'images');
},
filename: (req, file, cb) => {
cb(
null,
`${new Date().toISOString().replace(/:/g, '-')}` +
'-' +
file.originalname
);
}
});
app.use(express.static(path.join(__dirname, 'public')));
app.use('/images', express.static(path.join(__dirname, 'images')));;
//My routes
router.get('/user-page', isAuth, userRouter.getUserPage);
router.get('/user-page/:userId', isAuth, userRouter.getUserPage);