Fix dev node router extension detection issue
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -49,7 +49,7 @@ const envVars = Object.fromEntries(
|
|||||||
Object.entries(process.env).map(([key, value]) => [
|
Object.entries(process.env).map(([key, value]) => [
|
||||||
`process.env.${key}`,
|
`process.env.${key}`,
|
||||||
JSON.stringify(value),
|
JSON.stringify(value),
|
||||||
]),
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
const hotReloading = {
|
const hotReloading = {
|
||||||
@@ -176,10 +176,14 @@ if (command === "watch") {
|
|||||||
headers: req.headers,
|
headers: req.headers,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const urlObj = new URL(req.url, `http://${req.headers.host}`);
|
||||||
const extensionPattern = /\.[^/]+$/;
|
const extensionPattern = /\.[^/]+$/;
|
||||||
|
|
||||||
const proxyReq = http.request(options, (proxyRes) => {
|
const proxyReq = http.request(options, (proxyRes) => {
|
||||||
if (proxyRes.statusCode === 404 && extensionPattern.test(req.url)) {
|
if (
|
||||||
|
proxyRes.statusCode === 404 &&
|
||||||
|
extensionPattern.test(urlObj.pathname)
|
||||||
|
) {
|
||||||
res.writeHead(404, { "Content-Type": "text/plain" });
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
||||||
res.end("404 - Not Found");
|
res.end("404 - Not Found");
|
||||||
return;
|
return;
|
||||||
@@ -189,7 +193,7 @@ if (command === "watch") {
|
|||||||
const indexPath = path.join(
|
const indexPath = path.join(
|
||||||
import.meta.dirname,
|
import.meta.dirname,
|
||||||
"../dist",
|
"../dist",
|
||||||
"index.html",
|
"index.html"
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.readFile(indexPath, "utf8")
|
fs.readFile(indexPath, "utf8")
|
||||||
|
|||||||
Reference in New Issue
Block a user