Last active
April 19, 2022 15:14
-
-
Save paurakhsharma/b2ff8dec24a849b6b8770dd6cef14486 to your computer and use it in GitHub Desktop.
Firebase cloud functions image proxy server. I use it to overcome Flutter CORS issues with the images. ie. CORS Proxy server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cors = require('cors')({ origin: true }); | |
const request = require('request'); | |
functions.https.onRequest((req, res) { | |
cors(req, res, () => { | |
let url = req.query.url; | |
if (!url) { | |
url = req.body.url; | |
} | |
if (!url) { | |
res.status(403).send('URL is empty.'); | |
} | |
return request.get(url).pipe(res); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure you have installed
cors
andrequest
package.e.g