-
-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Mauro Amico <mauro.amico@gmail.com> Co-authored-by: nzambello <nzambello@protonmail.com> Co-authored-by: Tiberiu Ichim <tiberiu.ichim@gmail.com> Co-authored-by: Tiberiu Ichim <tiberiuichim@users.noreply.github.com>
- Loading branch information
1 parent
4e1bea2
commit 99d38d6
Showing
4 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import express from 'express'; | ||
import path from 'path'; | ||
import config from '@plone/volto/registry'; | ||
|
||
const staticMiddleware = express.static( | ||
process.env.BUILD_DIR | ||
? path.join(process.env.BUILD_DIR, 'public') | ||
: process.env.RAZZLE_PUBLIC_DIR, | ||
{ | ||
setHeaders: function (res, path) { | ||
const pathLib = require('path'); | ||
const base = pathLib.resolve(process.env.RAZZLE_PUBLIC_DIR); | ||
const relpath = path.substr(base.length); | ||
config.settings.serverConfig.staticFiles.some((elem) => { | ||
if (relpath.match(elem.match)) { | ||
for (const name in elem.headers) { | ||
res.setHeader(name, elem.headers[name] || 'undefined'); | ||
} | ||
return true; | ||
} | ||
return false; | ||
}); | ||
}, | ||
}, | ||
); | ||
|
||
export default function () { | ||
const middleware = express.Router(); | ||
middleware.all('*', staticMiddleware); | ||
middleware.id = 'staticResourcesProcessor'; | ||
return middleware; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters