What I'm trying to do:
A java api proxy that runs on https://127.0.0.1:443/api/
next to my user interface, which runs on non-SSL http://127.0.0.1:1337/ , to make some travel around the world with CORS.
My attempt:
- Api proxy on SSL port 443 for my non-SSL development port 1338.
- proxy my user interface until 1337
- Proxy 1137 -
:8080/index.html
and proxy 1338 - :8080/api/
- Access my application from localhost: 8080
My problem:
The user interface works very well ... but I can't hit the API at :8080/api/httpSession/init
Yes, I can still use the API in https://localhost/api/httpSession/init
api.js - Displays index.html at: 1337
var app = express(); app.all('*', function (req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS'); res.header('Access-Control-Allow-Headers', 'Content-Type'); next(); }); var options = { changeOrigin: true, target: { https: true } }; httpProxy.createServer(443, '127.0.0.1', options).listen(1338);
start.js - Proxies 1337 and 1338 in 8080
// First I start my two servers uiServer.start(); // renders index.html at 1337 apiServer.start(); // // I attempt to patch them back into one single non-SSL port. app .use('/', proxy({target: 'http://localhost:1337/'})) .all('/api/*', proxy({target: 'http://localhost:1338/'})) .listen(8080, function () { console.log('PROXY SERVER listening at http://localhost:%s', 8080); });
source share