From ac6e88b1bfde425f6b443ba618d3e3421cab1f81 Mon Sep 17 00:00:00 2001 From: Max Ehrlicher-Schmidt Date: Mon, 9 Nov 2020 15:00:35 +0100 Subject: [PATCH] Add token to requests --- src/app/graphql.module.ts | 8 +++++++- src/environments/environment.ts | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/graphql.module.ts b/src/app/graphql.module.ts index eaee8ab..5632d0a 100644 --- a/src/app/graphql.module.ts +++ b/src/app/graphql.module.ts @@ -9,10 +9,16 @@ import { import { HttpLink } from 'apollo-angular/http'; import { environment } from '../environments/environment'; + const uri = environment.apiUrl + '/graphql'; // <-- add the URL of the GraphQL server here const authMiddleware = new ApolloLink((operation, forward) => { - //Add token here <------------------------------------------------------- + //Add token here TODO: use AuthService to get the Token + operation.setContext({ + headers: { + authorization: localStorage.getItem('requestToken') || null, + } + }); return forward(operation).map((data) => { return data; }); diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 15242f4..434f3ef 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,6 +4,8 @@ export const environment = { production: false, + //apiUrl: "http://localhost:4000", + //authUrl: "http://localhost:8080" apiUrl: "http://173.212.197.169:4000", authUrl: "http://173.212.197.169:8080" };