@domenico
To forward HTTP requests to HTTPS using Webpack, you can use the http-proxy-middleware
package. Here's how to do it:
1
|
npm install http-proxy-middleware --save-dev |
1 2 3 4 5 6 7 8 9 10 11 |
const { createProxyMiddleware } = require('http-proxy-middleware'); module.exports = function(app) { app.use( '/api', createProxyMiddleware({ target: 'https://your-https-endpoint-here.com', changeOrigin: true, }) ); }; |
Replace 'https://your-https-endpoint-here.com'
with the URL of your HTTPS endpoint.
1 2 3 4 5 6 7 8 9 10 11 |
const proxy = require('./proxy'); module.exports = { // Other webpack configurations... devServer: { before: function(app) { proxy(app); }, }, }; |
Now, when you run your Webpack development server, all HTTP requests to /api
will be proxied to the specified HTTPS endpoint.