From f62b4f42977baac598cbab9d9af7bba31536686b Mon Sep 17 00:00:00 2001 From: Kunal Kundu Date: Sun, 1 Jan 2023 01:42:42 +0530 Subject: [PATCH] fix: resolve path correctly, make headers compatible --- src/commands/dev/dev.mjs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/commands/dev/dev.mjs b/src/commands/dev/dev.mjs index 6162d008222..3596b25e088 100644 --- a/src/commands/dev/dev.mjs +++ b/src/commands/dev/dev.mjs @@ -56,20 +56,20 @@ const netlifyBuildPromise = import('@netlify/build') const startStaticServer = async ({ settings }) => { const server = Fastify() + const rootPath = path.resolve(settings.dist) server.register(fastifyStatic, { - root: path.resolve(settings.dist), - // eslint-disable-next-line no-unused-vars - setHeaders: (res, _path, _stat) => { - res.setHeader('X-Powered-by', 'netlify-dev') - }, + root: rootPath, etag: false, + acceptRanges: false, + lastModified: false, }) server.setNotFoundHandler((_req, res) => { - res.code(404).sendFile('404.html', settings.dist) + res.code(404).sendFile('404.html', rootPath) }) server.addHook('onRequest', (req, reply, done) => { + reply.header('X-Powered-by', 'netlify-dev') const validMethods = ['GET', 'HEAD'] if (!validMethods.includes(req.method)) { reply.code(405).send('Method Not Allowed')