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.

Hi, I’m just trying to get my app ready for production. The app is hosted by Aws and is built like this: Route53 -> CloudFront -> ELB (no cluster, only SingleApp) CloudFront is used to make the app accessible via SSL. The Nodejs app listens on an HTTP port. Unfortunately the SessionCookie is not set. Here is my config:

session({
            genid: (req) => {
                return uuid() // use UUIDs for session IDs
            },
            secret: process.env.SESSION_SECRET,
            resave: false,
            saveUninitialized: false,        
            proxy:!dev,    
            store: new MongoStore({ mongooseConnection: mongoose.connection }),
            rolling: true,
            cookie:{
                secure:!dev,
                httpOnly:true,
                domain:hostName,
                expires: expiryDate
            }
        })

What am I doing wrong?

Thanks for your work 😃 .

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
renehauckcommented, Apr 22, 2019

Finally it works! 🎉 The solution is to select “whitelist” instead of “all” under “Cache Based on Selected Request Headers”. No idea why “all” is not “all”.

Under “WhiteList-Headers” the header “cloudfront-forwarded-proto” must be in the whitelist. Bildschirmfoto vom 2019-04-22 09-04-32

Now the following middleware must be created in the Express App before the session and cookie middleware:

server.use([(req, res, next) => {
    if (req.headers['cloudfront-forwarded-proto']) {
      req.headers['x-forwarded-proto'] = req.headers['cloudfront-forwarded-proto'];
    }
    next();
  },

Many thanks for the great help @dougwilson

0reactions
dougwilsoncommented, Oct 3, 2019

Please open a new issue with your information. If you believe this is a similar issue you can link to it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Low-Latency Content Delivery Network (CDN) - AWS
Amazon CloudFront is a content delivery network (CDN) service that helps you distribute your static and dynamic content quickly and reliably with high...
Read more >
Amazon CloudFront | Amazon CDN | Amazon Web Services
Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with ...
Read more >
Amazon CloudFront - Wikipedia
Amazon CloudFront is a content delivery network (CDN) operated by Amazon Web Services. Content delivery networks provide a globally-distributed network of ...
Read more >
What is AWS CloudFront? Everything You Need to Know ...
AWS CloudFront is a globally-distributed network offered by Amazon Web Services, which securely transfers content such as software, SDKs, videos, etc., to the ......
Read more >
Introduction to Amazon CloudFront - YouTube
Learn more about AWS CloudFront at – https://amzn.to/2UpRIG2In this video, you will learn about Amazon CloudFront. CloudFront is a fast ...
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