Skip to content

Commit

Permalink
move image path to the session scope.
Browse files Browse the repository at this point in the history
  • Loading branch information
shohhei1126 committed May 1, 2024
1 parent 80cd92f commit 2f824ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ app.use(i18n.init)
// static files
app.use('/', express.static(path.join(__dirname, '/public'), { maxAge: config.staticCacheTime, index: false }))
app.use('/docs', express.static(path.resolve(__dirname, config.docsPath), { maxAge: config.staticCacheTime }))
app.use('/uploads', express.static(path.resolve(__dirname, config.uploadsPath), { maxAge: config.staticCacheTime }))
app.use('/default.md', express.static(path.resolve(__dirname, config.defaultNotePath), { maxAge: config.staticCacheTime }))
app.use(require('./lib/metrics').router)

Expand Down Expand Up @@ -172,6 +171,12 @@ app.use(flash())
app.use(passport.initialize())
app.use(passport.session())

// routes with sessions
app.use('/uploads', (req, res, next) => {
if (req.isAuthenticated()) next()
else response.errorNotFound(req, res)
}, express.static(path.resolve(__dirname, config.uploadsPath), { maxAge: config.staticCacheTime }))

// check uri is valid before going further
app.use(require('./lib/middleware/checkURIValid'))
// redirect url without trailing slashes
Expand Down
1 change: 1 addition & 0 deletions lib/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
responseMaxLag: toIntegerConfig(process.env.CMD_RESPONSE_MAX_LAG),
privacyPolicyURL: process.env.CMD_PRIVACY_POLICY_URL,
imageUploadType: process.env.CMD_IMAGE_UPLOAD_TYPE,
uploadsPath: process.env.CMD_UPLOADS_PATH,
imgur: {
clientID: process.env.CMD_IMGUR_CLIENTID
},
Expand Down

0 comments on commit 2f824ff

Please sign in to comment.