fix: icons generation, 404 errors, static serving
All checks were successful
continuous-integration/drone the build was successful
All checks were successful
continuous-integration/drone the build was successful
This commit is contained in:
parent
f16ecc0766
commit
8756180ad1
@ -32,7 +32,7 @@ function getConfig(env) {
|
||||
: isProd;
|
||||
// Get environment variables to inject into our app.
|
||||
const environ = getClientEnvironment(env, publicUrl);
|
||||
|
||||
|
||||
const postCssConfig = {
|
||||
loader: require.resolve("postcss-loader"),
|
||||
options: {
|
||||
@ -170,9 +170,11 @@ function getConfig(env) {
|
||||
}
|
||||
: undefined
|
||||
}),
|
||||
new FaviconsWebpackPlugin(
|
||||
path.resolve(paths.clientDir, "images", "favicon-96x96.png")
|
||||
),
|
||||
new FaviconsWebpackPlugin({
|
||||
logo: path.resolve(paths.clientDir, "images", "favicon-96x96.png"),
|
||||
emitStatis: false,
|
||||
prefix: "static/icons-[hash]/"
|
||||
}),
|
||||
// Makes some environment variables available to the JS code, for example:
|
||||
// if (process.env.NODE_ENV === "production") { ... }. See `./env.js`.
|
||||
// It is absolutely essential that NODE_ENV was set to production here.
|
||||
|
@ -15,12 +15,21 @@ const errorHandler: express.ErrorRequestHandler = (
|
||||
// TODO: different content-type?
|
||||
res.status(err.statusCode).json(err.toJSON(isDev));
|
||||
} else if (err) {
|
||||
const internalError = new ApiError(
|
||||
"An internal server error has occurred",
|
||||
ErrorCode.Internal,
|
||||
err.stack ? err.stack : err
|
||||
);
|
||||
errorHandler(internalError, req, res, next);
|
||||
let error: ApiError;
|
||||
if (err.code === "ENOENT") {
|
||||
error = new ApiError(
|
||||
"The specified resource could not be found",
|
||||
ErrorCode.NotFound,
|
||||
err
|
||||
);
|
||||
} else {
|
||||
error = new ApiError(
|
||||
"An internal server error has occurred",
|
||||
ErrorCode.Internal,
|
||||
err.stack ? err.stack : err
|
||||
);
|
||||
}
|
||||
errorHandler(error, req, res, next);
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
@ -5,10 +5,11 @@ import * as serveStatic from "serve-static";
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
const paths = require("paths");
|
||||
|
||||
const staticDir = path.resolve(paths.publicDir, "static");
|
||||
const index = path.join(paths.publicDir, "index.html");
|
||||
|
||||
export default function serveApp(app: Express) {
|
||||
app.use(serveStatic(paths.clientBuildDir));
|
||||
app.use("/static", serveStatic(staticDir, { fallthrough: false }));
|
||||
app.get("/*", (req, res) => {
|
||||
res.sendFile(index);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user