Compare commits
2 Commits
3b28d6d467
...
e51e2701b3
| Author | SHA1 | Date | |
|---|---|---|---|
| e51e2701b3 | |||
| ada610d01f |
3
.env
3
.env
@@ -1 +1,2 @@
|
|||||||
VITE_SIMPLE_REST_URL=http://localhost:8081/core/api/admin
|
VITE_AUTH_URL=http://localhost:8080
|
||||||
|
VITE_GATEWAY_REST_URL=http://localhost:8081/core/api/admin
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const authProvider: AuthProvider = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
response = await fetch(
|
response = await fetch(
|
||||||
new Request("http://localhost:8080/atsp-idp/token", {
|
new Request(`${import.meta.env.VITE_AUTH_URL}/atsp-idp/token`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
body: new URLSearchParams({
|
body: new URLSearchParams({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useQueryEngine } from './hooks';
|
|||||||
|
|
||||||
export const dataProviderExtension = () => {
|
export const dataProviderExtension = () => {
|
||||||
const { fetchCommon } = useQueryEngine();
|
const { fetchCommon } = useQueryEngine();
|
||||||
const url = import.meta.env.VITE_SIMPLE_REST_URL;
|
const url = import.meta.env.VITE_GATEWAY_REST_URL;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
personList: (params: URLSearchParams) => fetchCommon(`${url}/person?${params}`),
|
personList: (params: URLSearchParams) => fetchCommon(`${url}/person?${params}`),
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const fetchJson = (url, options = {}) => {
|
|||||||
|
|
||||||
export const dataProvider = withLifecycleCallbacks(
|
export const dataProvider = withLifecycleCallbacks(
|
||||||
{
|
{
|
||||||
...simpleRestProvider(import.meta.env.VITE_SIMPLE_REST_URL, fetchJson),
|
...simpleRestProvider(import.meta.env.VITE_GATEWAY_REST_URL, fetchJson),
|
||||||
...dataProviderExtension(),
|
...dataProviderExtension(),
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -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