mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Replace URL with HTTP too
This commit is contained in:
parent
e552a32f24
commit
d9198cfddf
18
server.ts
18
server.ts
|
|
@ -173,9 +173,16 @@ export const createServer = (
|
||||||
return errorResponse("Route not found", 404);
|
return errorResponse("Route not found", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxy = await fetch(
|
const base_url_with_http = config.http.base_url.replace(
|
||||||
req.url.replace(config.http.base_url, "http://localhost:5173"),
|
"https://",
|
||||||
).catch(async (e) => {
|
"http://",
|
||||||
|
);
|
||||||
|
|
||||||
|
const replacedUrl = req.url
|
||||||
|
.replace(config.http.base_url, "http://localhost:5173")
|
||||||
|
.replace(base_url_with_http, "http://localhost:5173");
|
||||||
|
|
||||||
|
const proxy = await fetch(replacedUrl).catch(async (e) => {
|
||||||
await logger.logError(
|
await logger.logError(
|
||||||
LogLevel.ERROR,
|
LogLevel.ERROR,
|
||||||
"Server.Proxy",
|
"Server.Proxy",
|
||||||
|
|
@ -184,10 +191,7 @@ export const createServer = (
|
||||||
await logger.log(
|
await logger.log(
|
||||||
LogLevel.ERROR,
|
LogLevel.ERROR,
|
||||||
"Server.Proxy",
|
"Server.Proxy",
|
||||||
`The development Vite server is not running or the route is not found: ${req.url.replace(
|
`The development Vite server is not running or the route is not found: ${replacedUrl}`,
|
||||||
config.http.base_url,
|
|
||||||
"http://localhost:5173",
|
|
||||||
)}`,
|
|
||||||
);
|
);
|
||||||
return errorResponse("Route not found", 404);
|
return errorResponse("Route not found", 404);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue