jaehyuk-jang

Add env setting

...@@ -2,8 +2,10 @@ import { useMemo } from "react"; ...@@ -2,8 +2,10 @@ import { useMemo } from "react";
2 import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client"; 2 import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
3 import { concatPagination } from "@apollo/client/utilities"; 3 import { concatPagination } from "@apollo/client/utilities";
4 import merge from "deepmerge"; 4 import merge from "deepmerge";
5 -
6 export const APOLLO_STATE_PROP_NAME = "__APOLLO_STATE__"; 5 export const APOLLO_STATE_PROP_NAME = "__APOLLO_STATE__";
6 +import getConfig from "next/config";
7 +
8 +const { publicRuntimeConfig } = getConfig();
7 9
8 let apolloClient: any; 10 let apolloClient: any;
9 11
...@@ -11,7 +13,7 @@ function createApolloClient() { ...@@ -11,7 +13,7 @@ function createApolloClient() {
11 return new ApolloClient({ 13 return new ApolloClient({
12 ssrMode: typeof window === "undefined", 14 ssrMode: typeof window === "undefined",
13 link: new HttpLink({ 15 link: new HttpLink({
14 - uri: "http://localhost:5000/graphql", // Server URL (must be absolute) 16 + uri: publicRuntimeConfig.BACKEND_HOST ?? "http://localhost:5000/graphql", // Server URL (must be absolute)
15 credentials: "same-origin", // Additional fetch() options like `credentials` or `headers` 17 credentials: "same-origin", // Additional fetch() options like `credentials` or `headers`
16 }), 18 }),
17 cache: new InMemoryCache({ 19 cache: new InMemoryCache({
......
...@@ -20,4 +20,7 @@ module.exports = { ...@@ -20,4 +20,7 @@ module.exports = {
20 20
21 return config 21 return config
22 }, 22 },
23 + publicRuntimeConfig: {
24 + BACKEND_HOST: process.env.BACKEND_HOST,
25 + }
23 } 26 }
......