Allow disabling or configuration of CORS in @nrwl/angular:file-server
executor options
#14454
Closed
1 task done
Labels
Description
@nrwl/angular:file-server
executer that is set up when using Dynamic Module Federation in a Micro-frontends architecture has CORS enabled by default and there is no way to turn it off or to configure it.This causes CORS error when trying to fetch
remoteEntry.mjs
file of the MFE child application from the host MFE app in development mode. For example, host app running on localhost:4200 will try to fetch localhost:4201/remoteEntry.mjs and would fail because of CORS issues. Same would happen when fetching any additional chunk files.For production this is not an issue because then the child app files are served in a different way and CORS is configured on the infrastructure level. However, it is an annoyance during development if all I want to do is
nx serve my-host-app
.A workaround that we are using currently is to use
devRemotes
option when starting the MFE application stack. Doing so avoids usinghttp-server
and will use Webpack DevServer that can be configured to disable CORS checks. This workaround has to be done for each child app, in its@nrwl/angular:webpack-dev-server
options:Motivation
Resolving this issue would make development of applications in MFE architecture easier. Working with MFEs is complex enough as it is, we don't need tooling getting in the way.
Suggested Implementation
When serving child applications, we can see that there is CORS option set, but it is not configurable from Nx. Example output:
My proposal is to make CORS option via
@nrwl/angular:file-server
executor's options. It could looks something like this:Alternate Implementations
I see a couple of alternatives:
disableCors: boolean
The text was updated successfully, but these errors were encountered: