зеркало из https://github.com/mozilla/fxa.git
fix(content-server): Move serveStatic middleware after wildcard route
Because: * The MIME type was a mismatch for JS and CSS files without the static directory being set before the wildcard settings route This commit: * Ensures the serveStatic middleware comes after the wildcard route in production
This commit is contained in:
Родитель
d8533565cf
Коммит
43c0f441c5
|
@ -189,19 +189,8 @@ function makeApp() {
|
|||
const routeLogger = loggerFactory('server.routes');
|
||||
const routeHelpers = routing(app, routeLogger);
|
||||
|
||||
if (config.get('env') === 'production') {
|
||||
app.get(settingsPath, modifySettingsStatic);
|
||||
|
||||
addAllReactRoutesConditionally(app, routeHelpers, modifySettingsStatic);
|
||||
}
|
||||
|
||||
if (config.get('env') === 'development') {
|
||||
app.use(settingsPath, createSettingsProxy);
|
||||
|
||||
addAllReactRoutesConditionally(app, routeHelpers, createSettingsProxy);
|
||||
} else {
|
||||
app.get(settingsPath + '/*', modifySettingsStatic);
|
||||
}
|
||||
function addNonSettingsRoutes(middleware) {
|
||||
addAllReactRoutesConditionally(app, routeHelpers, middleware);
|
||||
|
||||
/* This creates `app.whatever('/path' ...` handlers for every content-server route and
|
||||
* excludes routes in `react-app.js` if corresponding feature flags are on. We manually add
|
||||
|
@ -211,12 +200,27 @@ function makeApp() {
|
|||
* route implementations. */
|
||||
routes.forEach(routeHelpers.addRoute);
|
||||
|
||||
// must come after route handling
|
||||
// must come after route handling but before wildcard routes
|
||||
app.use(
|
||||
serveStatic(STATIC_DIRECTORY, {
|
||||
maxAge: config.get('static_max_age'),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (config.get('env') === 'production') {
|
||||
app.get(settingsPath, modifySettingsStatic);
|
||||
|
||||
addNonSettingsRoutes(modifySettingsStatic);
|
||||
|
||||
app.get(settingsPath + '/*', modifySettingsStatic);
|
||||
}
|
||||
|
||||
if (config.get('env') === 'development') {
|
||||
app.use(settingsPath, createSettingsProxy);
|
||||
|
||||
addNonSettingsRoutes(createSettingsProxy);
|
||||
}
|
||||
|
||||
// it's a four-oh-four not found.
|
||||
app.use(fourOhFour);
|
||||
|
|
Загрузка…
Ссылка в новой задаче