question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't get cookies from client

See original GitHub issue

i followed the sample of authorized-https-endpoint and only added console.log to print the req.cookies, the problem is the cookies are always empty {} I set the cookies using clinet JS calls and they do save but from some reason, I can’t get them on the server side.

here is the full code of index.js, it’s exactly the same as the sample:

'use strict';

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const express = require('express');
const cookieParser = require('cookie-parser')();
const cors = require('cors')({origin: true});
const app = express();

const validateFirebaseIdToken = (req, res, next) => {
  console.log(req.cookies); //// <----- issue this is empty {} why?? 
  next();
};

app.use(cors);
app.use(cookieParser);
app.use(validateFirebaseIdToken);
app.get('/hello', (req, res) => {
  res.send(`Hello!!`);
});

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
sagivocommented, Jul 6, 2017

according to here it’s by design. i think it’s wrong design but at least answered my question. closing.

3reactions
sagivocommented, Aug 9, 2017

@paolomainardi not sure I understand. you can store cookies with JS regular way. if you want Firebase Function to read it it has to be called __session.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I retrieve the cookies on the client side?
When the user provides the right information, the 2 cookies get created on the backend and are sent to the client. I know...
Read more >
7 Keys to the Mystery of a Missing Cookie - Medium
HttpOnly : if true, the cookie cannot be accessed from within the client-side javascript code. Secure : cookie has to be sent over...
Read more >
middleware can't get client's cookies when access directly?
I have a middleware which is handling protected routes. And inside middleware I'm using cookies like request.headers.get('cookie').
Read more >
Set-Cookie - HTTP - MDN Web Docs
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent...
Read more >
Using cookies - Postman Learning Center
This field doesn't have an effect on Postman's behavior. ... Postman can capture cookies for a browser or client application using the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found