Add token to requests

pull/2/head
Max Ehrlicher-Schmidt 4 years ago
parent cebd3becbe
commit ac6e88b1bf

@ -9,10 +9,16 @@ import {
import { HttpLink } from 'apollo-angular/http'; import { HttpLink } from 'apollo-angular/http';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
const uri = environment.apiUrl + '/graphql'; // <-- add the URL of the GraphQL server here const uri = environment.apiUrl + '/graphql'; // <-- add the URL of the GraphQL server here
const authMiddleware = new ApolloLink((operation, forward) => { 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 forward(operation).map((data) => {
return data; return data;
}); });

@ -4,6 +4,8 @@
export const environment = { export const environment = {
production: false, production: false,
//apiUrl: "http://localhost:4000",
//authUrl: "http://localhost:8080"
apiUrl: "http://173.212.197.169:4000", apiUrl: "http://173.212.197.169:4000",
authUrl: "http://173.212.197.169:8080" authUrl: "http://173.212.197.169:8080"
}; };

Loading…
Cancel
Save