Reputation: 21
How to serve static file e.g index.html from different server
app.use(express.static('http://example.com/'))
Upvotes: 0
Views: 1388
Reputation: 1746
A proxy such as http-proxy-middleware
can do this:
var express = require('express');
var proxy = require('http-proxy-middleware');
var app = express();
app.use('/api', proxy({target: 'http://www.example.org', changeOrigin: true}));
app.listen(3000);
// http://localhost:3000/api/foo/bar -> http://www.example.org/api/foo/bar
see https://www.npmjs.com/package/http-proxy-middleware
Upvotes: 1