Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

290
Views
I cant access a JWT token from a get request in express
const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp()
const express = require('express');
const app = express();

const cors = require('cors');
const jwt = require('jsonwebtoken');
const bcrypt = require('bcrypt');

const initizalize = require('./passportConfig');
const bodyParser = require('body-parser')
app.use(bodyParser.json())


const cookieParser = require("cookie-parser");
app.use(cookieParser());

const db = admin.firestore()


app.get('/checkToken', function(req, res) {
  console.log('Cookies: ', req.cookies.token);
  res.sendStatus(200);
});



exports.app = functions.https.onRequest(app);

Example Image of Error

I can see on chrome dev tools that there is a token there but for some reason the token is undefined when the path /checktoken is called.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try using credentials options in fetch options. Allowed values are 'same-origin' for same-origin requests, 'include' for all requests, 'omit' to omit the use of cookies. Fetch by default uses `'omit``. Docs

If you are using credentials: 'include', you must set the Access-Control-Allow-Origin header to * at the backend. If you are using cors module then simply do app.use(cors()), or app.use(cors({ origin: '*' })). Both are same.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!