How can access that data without getting blocked by cors in server cloudways? Im using react.js
Asked
Active
Viewed 125 times
1 Answers
0
You can write a little proxy for your react application that is used in your dev environment.
For this, you can simply use the package http-proxy-middleware
:
https://www.npmjs.com/package/http-proxy-middleware
After installation, you need to create a file, e.g. "setupProxy.js" in your
/src
directory with the according settings. Something like this can work:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = (app) => {
app.use(
'/storage',
createProxyMiddleware({
target: 'https://firebasestorage.googleapis.com',
changeOrigin: true,
pathRewrite: {
'/storage': '/',
},
})
);
};
In you app, you then need not to call https://firebasestorage.googleapis.com/whateverpath
, but your proxy: /storage/whateverpath
.

grenzbotin
- 2,489
- 1
- 12
- 14