DEV Community

Discussion on: GraphQL Server Not Setting JWT Cookie

Collapse
 
doylecodes profile image
Ryan Doyle

I did! Basically, it all came down to needing to pass in various options that were CORS related to both my frontend and backend. My main issue was that I was using apollo-server-express with cors middleware, but didn;'t realize that apollo-server-express had some cors built in and both were conflicting. I ended up doing:

server.applyMiddleware({
  app,
  path: '/',
  cors: false, // disables the apollo-server-express cors to allow the cors middleware use
})

Then my cors middleware worked and the tokens/headers were all getting passed correctly.

You can see my codebase here

ryanmdoyle / thermoFisherSci

Part Inventory description tracker/editor/exporter. Allows input and exiting of part descriptions in multiple languages to export as HTML to be used in web applications.

ThermoFisher Scientific Part Descriptions

Part Inventory description tracker/editor/exporter. Allows input and exiting of part descriptions in multiple languages to export as HTML to be used in web applications.

You can start the application by:

  1. npm install from both frontend and backend folders.
  2. You'll need to create a Prisma account and deploy to prisma from backend.
  3. Create a .env file in backend with:
  • DB_ENDPOINT (set to your prisma endpoint)
  • DB_SECRET (make a random secret for prisma to use)
  • USER_SECRET (a random secret for the app to use)
  • COOKIE_SECRET (something random for cookie generation)
  • FRONTEND_URL=http:localhost:3000
  • APP_SECRET (something random for the app to use)
  1. Make .env in frontend
  • NODE_ENV=development
  1. npm run dev from both frontend (localhost: 3000) and backend (localhost:4000)
  2. See app from locahost:3000

.
Collapse
 
fcpauldiaz profile image
Pablo Díaz

Thank you Ryan :)