GET request with custom "company_id" header works locally but header not present in GCP App Engine

Viewed 109

I'm manually attaching the 'company_id' header from the frontend. I can confirm with the browser that the header is correct and present in production.

It also works locally without any issues and the header is retrieved.

However, when deployed to production as App Engine with Nodejs 12 in GCP -- the custom header will no longer be present on any request.

I've logged all headers and the whole request object on the console to see what's actually available in-memory and I can confirm that the express app does not see the custom header.

Any help debugging this further is appreciated.

1 Answers

I reproduced your issue and I found something interesting, App Engine is removing all headers with underscore, I performed my test using postman and the code below.

If you use company-id you will be able to see the header on App Engine side.

'use strict';

// [START gae_node_request_example]
const express = require('express');

const app = express();

app.get('/', (req, res) => {
  res.status(200).send(JSON.stringify(req.headers)).end();
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});
// [END gae_node_request_example]

module.exports = app;

Related