fix: enable cors on login/logout api

This commit is contained in:
MTG2000
2022-06-05 21:11:49 +03:00
parent c9845b28da
commit 41b72cf6ad
10 changed files with 30 additions and 14 deletions

View File

@@ -1,19 +1,17 @@
import { ApolloClient, HttpLink, InMemoryCache, from, Reference, FieldPolicy } from "@apollo/client";
import { onError } from "@apollo/client/link/error";
import { RetryLink } from "@apollo/client/link/retry";
import CONSTS from "./consts";
import { CONSTS } from "src/utils";
let apiClientUri = CONSTS.apiEndpoint + '/graphql';
const httpLink = new HttpLink({
uri: apiClientUri,
credentials: process.env.REACT_APP_API_END_POINT?.includes('localhost') ? 'include' : "same-origin"
credentials: "include"
});
const errorLink = onError(({ graphQLErrors, networkError, response }) => {
console.log('AHIHIHA');
if (graphQLErrors)
graphQLErrors.forEach(({ message, locations, path }) =>
console.log(

View File

@@ -0,0 +1,5 @@
const CONSTS = {
apiEndpoint: 'http://localhost:8888/.netlify/functions'
}
export default CONSTS;

View File

@@ -1,5 +0,0 @@
const CONSTS = {
apiEndpoint: process.env.REACT_APP_API_END_POINT ?? '/.netlify/functions'
}
export default CONSTS;

1
src/utils/index.ts Normal file
View File

@@ -0,0 +1 @@
export { default as CONSTS } from './consts/consts'