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