mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-05 22:15:36 +05:00
fix: add missing cors and content-type headers
This commit is contained in:
parent
51c5bf01da
commit
cc9a9c3a2c
14 changed files with 116 additions and 89 deletions
|
@ -1,14 +1,10 @@
|
|||
export const corsHeaders = {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
|
||||
"Access-Control-Allow-Methods": "GET,HEAD,POST,OPTIONS",
|
||||
"Cache-Control": "no-cache",
|
||||
};
|
||||
|
||||
export const resHeaders = {
|
||||
...corsHeaders,
|
||||
"Content-Type": "application/json",
|
||||
};
|
||||
|
||||
export const USERAGENTS = [
|
||||
"Mozilla/5.0 (Linux; Android 12.0; LG G8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.2.7124.71 Mobile Safari/537.36",
|
||||
"Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.5.1269.13 Safari/537.36",
|
||||
|
@ -37,7 +33,9 @@ export const USERAGENTS = [
|
|||
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:128.0) Gecko/128.0 Firefox/128.0",
|
||||
];
|
||||
|
||||
export function asJSON(res, object: any, status: number) {
|
||||
export function asJSON(req, res, object: any, status: number) {
|
||||
corsHeaders["Access-Control-Allow-Origin"] = req.headers.origin || "*";
|
||||
|
||||
res.status(status).type("application/json");
|
||||
res.set(corsHeaders);
|
||||
res.send(JSON.stringify(object));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue