Closed pradeepnidiganti closed 6 years ago
Assuming bigImage.png
lives at https://externalhost.com/foo/bigImage.png
you could accomplish this by adding a piece of proxying middleware after express-processimage (untested):
const proxy = require('http-proxy-middleware');
app.use('/externalImages', express()
.use(require('express-processimage')())
.use(proxy({target: 'https://externalhost.com/foo'}));
Then http://localhost:1337/externalImages/bigImage.png?resize=400,300 ought to work. Is that what you had in mind?
but i am getting another issue while using above example "Router.use() requires a middle-ware function but got a Object"
Hmm, sounds like you're using a really old version of express? Could you try upgrading to 4.x?
No , i have used the latest version only the version of express is "express": "^4.16.2"
Ah, is app
an express.Router
instance? I assumed it would be an express app:
const express = require('express');
const proxy = require('http-proxy-middleware');
const app = express();
app.use('/externalImages', express()
.use(require('express-processimage')())
.use(proxy({target: 'https://externalhost.com/foo'}));
Thnq i got it :+1:
http://localhost:1337/bigImage.png?resize=400,300
rather than using the local image how to resize the external server image