DtsPlugin not working with multiple domains in host and HTTPS protocol with self-signed certificate
Describe the bug
If the static files are served by the webpack-dev server with the host localhost.example.com, then when you try to load the manifest using the DTS plugin, the URL is transformed into 127.0.0.1.example.com/mf-manifest.json. This results in an error:
cause: Error: getaddrinfo ENOTFOUND 127.0.0.1.example.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: '127.0.0.1.example.com'
}
}
This problem is solved by adding lines like this to ets/hosts:
127.0.0.1 127.0.0.1.example.com
127.0.0.1 localhost.example.com
And adding the allowedHosts: 'all' property to the devServer
After that, when you try to call https://127.0.0.1.example.com:4178/mf-manifest.json an error occurs:
cause: Error: self-signed certificate
Reproduction
Turn on https/ssl for example test apps react-ts-host and react-ts-remote
OR
https://github.com/dimohqa/example-mf-dts-bug
Used Package Manager
npm
System Info
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M2
Memory: 62.02 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.16.0/bin/yarn
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
pnpm: 8.15.6 - ~/.nvm/versions/node/v18.16.0/bin/pnpm
Browsers:
Chrome: 123.0.6312.123
Safari: 17.4.1
Validations
- [X] Read the docs.
- [X] Read the common issues list.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Module federation issue and not a framework-specific issue.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hello @dimohqa. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 5 days.
Added repo for reproduction: https://github.com/dimohqa/example-mf-dts-bug
@2heal1 Help with this issue
As the issue was labelled with need reproduction, but no response in 5 days. This issue will be closed. Feel free to comment and reopen it if you have any further questions. For background, see Why reproductions are required.
由于该 issue 被标记为 "需要重现",但在 5 天内没有回应,因此该 issue 将被关闭。如果你有任何进一步的问题,请随时发表评论并重新打开该 issue。背景请参考 为什么需要最小重现。
Reproduction was added @zhoushaw @2heal1
is there any information?
@dimohqa it's a good security practice to keep enabled self-signed certificate check.
If you still need to overcome this, you can set the environment variable NODE_TLS_REJECT_UNAUTHORIZED=0 directly inside your npm script.
Just tried, using NODE_TLS_REJECT_UNAUTHORIZED=0 makes it working.
No fix needed on our side.