can't get cookies from client
See original GitHub issuei 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:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
according to here it’s by design. i think it’s wrong design but at least answered my question. closing.
@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
.