Sep 13, 2020 04:33 AM
Hi everyone,
This question might sound a bit naive and I apologize in advance. What is the best way to set up a proxy to a backend app in the scripting blocks dev environment?
When using create-react-app I make the proxy in the package.json
"proxy": {
"/api/projects": {
"target": "http://localhost:3000"
}
or more recently using http-proxy-middleware and creating a setupProxy.js on my src folder.
const { createProxyMiddleware } = require(‘http-proxy-middleware’);
module.exports = function (app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:3000',
changeOrigin: true,
})
);
};
I am not quite sure to set that when using the blocks. Thanks so much for your help!
Feb 25, 2022 11:09 AM
Mar 03, 2022 10:56 AM
Generally, you will use a proxy if your school or workplace provides it. You can also use a proxy to hide your IP address or access geo-blocked sites not available in your country.
Jun 12, 2023 06:26 AM
Apologies for the delayed response, considering that the thread is a few years old. Proxy setup methods may have evolved since then, so it's worth checking for any updates or changes in the preferred approach.
In general, setting up a proxy in the scripting blocks dev environment would still involve using a reverse proxy server like NGINX or Apache. These servers act as intermediaries, forwarding requests to your backend app. Configuration details may vary, so it's a good idea to consult the documentation or resources specific to the server you choose.
For more information and up-to-date guidance on setting up proxies, you can visit proxys.io. They offer valuable resources and insights into proxy server configurations.