try to fix the CORS problems vol. 1
This commit is contained in:
@@ -2,6 +2,12 @@ export const useQueryEngine = () => {
|
||||
const defaultHeaders = {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
Origin: "http://localhost:3000",
|
||||
Referer: "http://localhost:3000",
|
||||
"Access-Control-Allow-Origin": "http://localhost:3000",
|
||||
"Access-Control-Allow-Headers":
|
||||
"Origin, X-Requested-With, Content-Type, Accept, X-XSRF-TOKEN, Authorization, Cookie",
|
||||
"Access-Control-Allow-Credentials": true,
|
||||
};
|
||||
|
||||
const response = async (request: Request) => {
|
||||
@@ -37,6 +43,7 @@ export const useQueryEngine = () => {
|
||||
|
||||
return await response(
|
||||
new Request(url, {
|
||||
mode: "cors",
|
||||
credentials: "include",
|
||||
...(options?.method ? { method: options.method } : { method: "GET" }),
|
||||
...(options.replaceHeaders
|
||||
@@ -46,6 +53,7 @@ export const useQueryEngine = () => {
|
||||
...defaultHeaders,
|
||||
Authorization: `Bearer ${localStorage.getItem("user")}`,
|
||||
"X-XSRF-TOKEN": localStorage.getItem("user"),
|
||||
"Access-Control-Request-Method": options?.method ? options.method : "GET",
|
||||
...(options?.headers ? { ...options.headers } : {}),
|
||||
}),
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user