Skip to content

Commit 0525a68

Browse files
authored
dashboard: detect API url by window.location (#80)
1 parent 5041dca commit 0525a68

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

dashboard/src/lib/apollo.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,13 @@ function createApolloClient(initialState = {}) {
9595
const ssrMode = typeof window === 'undefined';
9696
const cache = new InMemoryCache().restore(initialState);
9797

98+
let apiUrl = process.env.API_URL;
99+
if (typeof window !== 'undefined') {
100+
apiUrl = `${window.location.protocol}//${window.location.host}/graphql`;
101+
}
102+
98103
const httpLink = new HttpLink({
99-
uri: process.env.API_URL,
104+
uri: apiUrl,
100105
credentials: 'same-origin',
101106
fetch,
102107
});

0 commit comments

Comments
 (0)