I've deployed my Node.js + Express API on AWS EB and routed a custom domain with its HTTPS certificate.
Then I've a static HTML file in static directory of this environment "/public" and the HTML file is served greatly if opened on a browser with HTTP.
But when I open the same HTML file with HTTPS it seems to serve the file content as a string in this way:
<html>
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
"<!DOCTYPE html> ... {all my html page content}"
</pre>
</body>
</html>
How can i serve this html file with HTTPS?
My error was that i firstly setted content-type response header like this:
function decode(req, res, next) {
res.setHeader("Content-Type", "application/json; charset=utf-8");
next();
}
app.use(decode);
Removing this it worked.
I still don't know why it worked with HTTP and not with HTTPS.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.