refactor(server): moved the server files outside the src to improve static files
This commit is contained in:
19
server/services/ocme/ocmeService.ts
Normal file
19
server/services/ocme/ocmeService.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type {Context} from "hono";
|
||||
|
||||
export const ocmeService = async (c: Context) => {
|
||||
const url = new URL(c.req.url);
|
||||
|
||||
const ocmeUrl = `http://localhost:${process.env.OCME_PORT}${url.pathname.replace("/ocme", "")}`;
|
||||
|
||||
console.log(ocmeUrl);
|
||||
const ocmeResponse = await fetch(ocmeUrl, {
|
||||
method: c.req.method,
|
||||
headers: c.req.raw.headers,
|
||||
body: c.req.method !== "GET" && c.req.method !== "HEAD" ? await c.req.text() : undefined,
|
||||
});
|
||||
|
||||
return new Response(ocmeResponse.body, {
|
||||
status: ocmeResponse.status,
|
||||
headers: ocmeResponse.headers,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user