Skip to content

Commit

Permalink
INC-1335: Sync upstream changes to template (#860)
Browse files Browse the repository at this point in the history
Disable 301 redirects on static content folders without CSP header (hmpps-template-typescript#383)
  • Loading branch information
ushkarev authored Nov 6, 2024
1 parent 0318cea commit 861bf6b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions server/middleware/setUpStaticResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function setUpStaticResources(): Router {
router.use(compression())

// Static Resources Configuration
const cacheControl = { maxAge: config.staticResourceCacheDuration }
const staticResourcesConfig = { maxAge: config.staticResourceCacheDuration, redirect: false }

// frontend assets
Array.of(
Expand All @@ -22,17 +22,18 @@ export default function setUpStaticResources(): Router {
'/node_modules/@ministryofjustice/frontend/moj/assets',
'/node_modules/@ministryofjustice/frontend',
).forEach(dir => {
router.use('/assets', express.static(path.join(process.cwd(), dir), cacheControl))
router.use('/assets', express.static(path.join(process.cwd(), dir), staticResourcesConfig))
})
router.use(
'/assets/js/jquery.min.js',
express.static(path.join(process.cwd(), '/node_modules/jquery/dist/jquery.min.js'), cacheControl),
express.static(path.join(process.cwd(), '/node_modules/jquery/dist/jquery.min.js'), staticResourcesConfig),
)

// downloads
router.use(
'/user-guide.pdf',
express.static(path.join(process.cwd(), '/dist/assets/downloads/user-guide.pdf'), {
...staticResourcesConfig,
maxAge: '2h',
setHeaders: res => res.setHeader('Content-Type', 'application/pdf'),
}),
Expand Down

0 comments on commit 861bf6b

Please sign in to comment.