mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 00:18:19 +01:00
Fix some shenanigans with routes
This commit is contained in:
parent
04dcaa94aa
commit
4755451404
|
|
@ -68,11 +68,11 @@
|
|||
"eslint-formatter-summary": "^1.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"prettier": "^3.1.0",
|
||||
"typescript": "^5.3.2",
|
||||
"typescript": "latest",
|
||||
"unocss": "latest",
|
||||
"@vitejs/plugin-vue": "latest",
|
||||
"@vueuse/head": "^2.0.0",
|
||||
"vite": "^5.0.4",
|
||||
"vite": "latest",
|
||||
"vite-ssr": "^0.17.1",
|
||||
"vue": "^3.3.9",
|
||||
"vue-router": "^4.2.5",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import type { RouteRecordRaw } from "vue-router";
|
||||
import indexVue from "./pages/index.vue";
|
||||
import authorizeVue from "./pages/oauth/authorize.vue";
|
||||
import registerIndexVue from "./pages/register/index.vue";
|
||||
|
|
@ -8,4 +9,4 @@ export default [
|
|||
{ path: "/oauth/authorize", component: authorizeVue },
|
||||
{ path: "/register", component: registerIndexVue },
|
||||
{ path: "/register/success", component: successVue },
|
||||
];
|
||||
] as RouteRecordRaw[];
|
||||
|
|
|
|||
24
server.ts
24
server.ts
|
|
@ -137,7 +137,11 @@ export const createServer = (
|
|||
configManager,
|
||||
parsedRequest,
|
||||
});
|
||||
} else if (matchedRoute?.name === "/[...404]") {
|
||||
} else if (matchedRoute?.name === "/[...404]" || !matchedRoute) {
|
||||
if (new URL(req.url).pathname.startsWith("/api")) {
|
||||
return errorResponse("Route not found", 404);
|
||||
}
|
||||
|
||||
// Proxy response from Vite at localhost:5173 if in development mode
|
||||
if (isProd) {
|
||||
if (new URL(req.url).pathname.startsWith("/assets")) {
|
||||
|
|
@ -164,21 +168,17 @@ export const createServer = (
|
|||
config.http.base_url,
|
||||
"http://localhost:5173"
|
||||
)
|
||||
).catch(async e => {
|
||||
await logger.logError(
|
||||
LogLevel.ERROR,
|
||||
"Server.Proxy",
|
||||
e as Error
|
||||
);
|
||||
return errorResponse("Route not found", 404);
|
||||
});
|
||||
);
|
||||
|
||||
if (proxy.status !== 404) {
|
||||
if (
|
||||
proxy.status !== 404 &&
|
||||
!(await proxy.clone().text()).includes("404 Not Found")
|
||||
) {
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
return errorResponse("Route not found", 404);
|
||||
return errorResponse("Route not found", 404);
|
||||
}
|
||||
} else {
|
||||
return errorResponse("Route not found", 404);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue