Skip to content

Instantly share code, notes, and snippets.

@rehrumesh
Created July 5, 2020 10:16
Show Gist options
  • Save rehrumesh/bb4950b007915b156797c4ae04cf88ff to your computer and use it in GitHub Desktop.
Save rehrumesh/bb4950b007915b156797c4ae04cf88ff to your computer and use it in GitHub Desktop.
Enabling proxy for react micro frontend
module.exports = (app) => {
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
next();
});
};
@dhirender-rsi
Copy link

Hi Rehrumesh,

I had read your article regarding how we can build micro frontends and use them together in hosted/container frontends. Your article was very helping to me. Thanks for sharing your experience/knowledge.

In my project, client has provided container micro frontend where we need to run our child micro frontend. So we have developed this child module as per requirement. Now when we run the same in container environment, container throws cors error for accessing "asset-manifest.json" file.

image

Container frontend is running on: http://localhost:3000
My module is running on: http://esl.local.com (I have added this virtual host for module)

Please note, I am running build of my module in the container frontend.

To resolve this issue, I have added "src/setupProxy.js" in my module with the content shared by you for this file. But still I am getting same issue.

Can you please guide me what I am missing or implemented any wrong thing? Thanks in Advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment