diff --git a/app/app.vue b/app/app.vue index 63fc510..17562cf 100644 --- a/app/app.vue +++ b/app/app.vue @@ -7,6 +7,7 @@ boxArtifacts settingsSettings + logout Log Out diff --git a/app/utils/Api.ts b/app/utils/Api.ts index a8ec0cc..f87ffc2 100644 --- a/app/utils/Api.ts +++ b/app/utils/Api.ts @@ -4,7 +4,7 @@ export class MavenApi { static create() { - return build("/proxy/api"); + return build("/api"); } } diff --git a/server/routes/api/[...path].ts b/server/routes/api/[...path].ts new file mode 100644 index 0000000..70c92d9 --- /dev/null +++ b/server/routes/api/[...path].ts @@ -0,0 +1,24 @@ +import type {H3Event} from "h3"; + +export default defineEventHandler(async (event) => +{ + event.headers.delete("host"); + event.headers.delete("origin"); + + return sendProxy(event, process.env.NUXT_PUBLIC_BASE_URL + event.path, { + fetchOptions: { + method: event.method, + headers: event.headers, + body: await readBody(event) + } + }); +}) + +async function readBody(event: H3Event) +{ + if (["POST", "PUT", "PATCH"].includes(event.method)) + { + return await readRawBody(event); + } + return undefined; +} \ No newline at end of file