Skip to content

Commit

Permalink
Merge pull request #200 from StarfilesFileSharing/alpha
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
QuixThe2nd authored Nov 23, 2024
2 parents d219ebc + 3b48412 commit 41a1a70
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/rpc/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,20 @@ class RPCServer {
};

handleRequest = async (req: Request): Promise<Response> => {
console.log(`Request: ${req.url}`);
const url = new URL(req.url);

const headers = new Headers({
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type",
});
try {
console.log(`Request: ${req.url}`);
const url = new URL(req.url);

if ((url.pathname === "/" || url.pathname === "/docs") && req.headers.get("upgrade") !== "websocket") {
headers.set("Location", "/docs/");
return new Response("", { headers: headers, status: 301 });
}
if ((url.pathname === "/" || url.pathname === "/docs") && req.headers.get("upgrade") !== "websocket") {
headers.set("Location", "/docs/");
return new Response("", { headers: headers, status: 301 });
}

try {
try {
const url = new URL(req.url);
const filePath = `./public${url.pathname.endsWith("/") ? `${url.pathname}index.html` : url.pathname}`;
Expand Down

0 comments on commit 41a1a70

Please sign in to comment.