core icon indicating copy to clipboard operation
core copied to clipboard

DtsPlugin not working with multiple domains in host and HTTPS protocol with self-signed certificate

Open dimohqa opened this issue 1 year ago • 5 comments

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

dimohqa avatar Apr 15 '24 09:04 dimohqa

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.

github-actions[bot] avatar Apr 15 '24 09:04 github-actions[bot]

Added repo for reproduction: https://github.com/dimohqa/example-mf-dts-bug

dimohqa avatar Apr 17 '24 04:04 dimohqa

@2heal1 Help with this issue

zhoushaw avatar Apr 17 '24 04:04 zhoushaw

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。背景请参考 为什么需要最小重现

github-actions[bot] avatar Apr 23 '24 00:04 github-actions[bot]

Reproduction was added @zhoushaw @2heal1

zackarychapple avatar Apr 25 '24 13:04 zackarychapple

is there any information?

dimohqa avatar May 31 '24 15:05 dimohqa

@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.

ilteoood avatar May 31 '24 15:05 ilteoood

Just tried, using NODE_TLS_REJECT_UNAUTHORIZED=0 makes it working. No fix needed on our side. image

ilteoood avatar Jun 13 '24 20:06 ilteoood