Skip to content

Commit

Permalink
fix a problem with not sending cookies - remember to set cors settings!
Browse files Browse the repository at this point in the history
  • Loading branch information
drillprop committed Feb 27, 2019
1 parent 2e2561f commit 42a091e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ApolloServer } from 'apollo-server-express';
import express from 'express';
import cookieParser from 'cookie-parser';
import express from 'express';
import jwt from 'jsonwebtoken';
import Query from './graphql/resolvers/Query';
import db from './db';
import Mutation from './graphql/resolvers/Mutation';
import Query from './graphql/resolvers/Query';
import typeDefs from './graphql/schema';
import db from './db';

const resolvers = { Query, Mutation };

const app = express();
Expand All @@ -26,7 +25,9 @@ app.use((req, res, next) => {
next();
});

server.applyMiddleware({ app, path: '/' });
const corsOptions = { credentials: true, origin: process.env.FRONTEND_URL };

server.applyMiddleware({ app, path: '/', cors: corsOptions });

app.listen({ port: 4000 }, () => {
console.log(`server ready at ${server.graphqlPath}`);
Expand Down

0 comments on commit 42a091e

Please sign in to comment.