I am trying to render static file. I came across the sendFile() method but it is not working with proxy. I need help. Here is my code.
var express = require('express');
const proxy = require('express-http-proxy');
var process = require('process');
var app = express();
app.set('port', (process.env.PORT || 8080));
app.use('$Variable', express.static(__dirname + '$Variable'));
app.use('/', proxy(function(request, response) {
return 'http://localhost:8000' + request.url
}))
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
app.listen(app.get('port'));
setTimeout(function() {
process.exit();
}, 100000);
I want something like this does anyone has idea? What can I do to replace the $variable with path to my files. NOTE: $VARIABLE is just there to showcase what I am trying to mean. It does not means that I am trying to use PHP in node.js. Think before you become a professor.
/test1/foo? You really haven't specified enough info in your question for people to know how to help. Please edit the question to include all relevant detail.