0

We have app.js running on server and index.html on the server where app.js is located. app.js code is as below.

var express = require('express');
var engine = require('consolidate');

var app = express();

app.set('views', __dirname);
app.engine('html', engine.mustache);
app.set('view engine', 'html');

app.use(express.static('.'));

app.get('/', function(req, res) {
    console.log("Got request for index.html");
    res.render('index.html');
});

app.listen(5000, '0.0.0.0');

From our mobile app (java code), we are hitting the server with GET request and we are sending encrypted user data as one of the headers for that GET request. Once our app.js receives the request, it will serve index.html file. Is there any way we can read the encrypted data in index.html by using javascript. I have gone through some stack overflow questions as below but not able to find the solution.

kadina
  • 5,042
  • 4
  • 42
  • 83
  • Use a middleware before the express.static middleware. https://expressjs.com/en/guide/using-middleware.html – gp. Sep 17 '20 at 17:54
  • Didn't understand how writing one more middleware helps here. I need to pass the request headers to index.html. Is there any way to access the request headers in index.html? Can you please elaborate. – kadina Sep 18 '20 at 00:43
  • are you looking at how to inject the request headers in the request from client or how to extract it from the request on the server? I understood you looking for later, /index.html request is handled by express.static middleware and if you add one more before this, you can read the request haader and then the call gets processed by next middleware to serve index.html. – gp. Sep 18 '20 at 09:14

0 Answers0