You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
i found this project and thought, it would help me, to get a small (reverse) proxy, to catch up a full HTML site from an external resource, to avoid the first pain with CORS.
const express = require('express')
const cors = require('cors')
const { createProxyMiddleware } = require('http-proxy-middleware')
const app = express()
app.use(cors())
app.use(createProxyMiddleware({
router: (req) => new URL(req.path.substring(1)),
pathRewrite: (path, req) => (new URL(req.path.substring(1))).pathname,
changeOrigin: true,
logger: console
}))
app.listen(8088, () => {
console.info('proxy server is running on port 8088')
})
When i now attach a website, which has full paths for styles, images and so on, its working flawless - if they are relative, they are not being converted.
Does anybody perhaps know, how to deal with that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
i found this project and thought, it would help me, to get a small (reverse) proxy, to catch up a full HTML site from an external resource, to avoid the first pain with CORS.
I used this example to start:
https://dev.to/decker67/write-your-own-cors-proxy-with-nodejs-in-no-time-30f9
When i now attach a website, which has full paths for styles, images and so on, its working flawless - if they are relative, they are not being converted.
Does anybody perhaps know, how to deal with that?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions