quasarframework / quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time
https://quasar.dev
MIT License
25.85k stars 3.5k forks source link

Capacitor and webpack devserver : allowedHosts seems to be not taken into account #12145

Open laferte-tech opened 2 years ago

laferte-tech commented 2 years ago

What happened?

Hello,

When building a Capacitor App in dev mode, i would like to have a host like :

host: 'mysubdomain.eu.ngrok.io'

This host config goes to the devServer block of Quasar.conf.js and it's used by the capacitor.config.json in the android folder to start the app.

I want to have this because i found no better way to test my app on my phone and having secureContext enabled.

To make it work, i need to disable the host check by setting :

allowedHosts: 'all', or by specifying the host name.

The problem that, it seems, this parameter is not taken into account when Quasar start the dev server.

Looking Quasar source code, when dev server is starting, Quasar is doing this

try {
    const openPort = await findPort(port, host)
    if (port !== openPort) {
      warn()
      warn(`️️Setting port to closest one available: ${openPort}`)
      warn()

      port = openPort
    }
  }

this findPort leads to this code

    const tester = net.createServer()
      .once('error', err => {
        if (err.code === 'EADDRNOTAVAIL') {
          reject(new Error('ERROR_NETWORK_ADDRESS_NOT_AVAIL'))
        }

So we can see that in any case we try to create the server and at no time i found an exception where we sould bypass this check when allowedHosts is filled.

Maybe i'm mistaken but this is my understanding.

What did you expect to happen?

To have allowedHosts taken into account in devServer.

Reproduction URL

not successed to have a sandebox in capacitor mode (because it needs Android Studio to start)

How to reproduce?

start a Capacitor project put a host outside local network in devServer fill allowedHosts with the host name See the error: 'Invalid host specified. No network address matches. Please specify another one."

Flavour

Quasar CLI (@quasar/cli | @quasar/app)

Areas

Capacitor Mode

Platforms/Browsers

No response

Quasar info output

No response

Relevant log output

No response

Additional context

Thank you very much

github-actions[bot] commented 2 years ago

Hi @GrandOurs35! 👋

It looks like you provided an invalid or unsupported reproduction URL. Do not use any service other than Codepen, jsFiddle, Codesandbox, and GitHub. Make sure the URL you provided is correct and reachable. You can test it by visiting it in a private tab, another device, etc. Please edit your original post above and provide a valid reproduction URL as explained.

Without a proper reproduction, your issue will have to get closed.

Thank you for your collaboration. 👏

devslayertech commented 2 years ago

I have this error too when use "quasar dev" with Vite! I want to specify hostname to open the app with domain but failed: image

"App • ⚠️ Invalid host specified. No network address matches. Please specify another one."

AkliOnet commented 1 year ago

it ' s seems related to my problem also , i just add the host to my domain and the dev server don't start but print :

Invalid host specified. No network address matches. Please specify another one

how to specify a host for all the mode with quasar dev and an host for all the mode for quasar build ?

amav96 commented 8 months ago

I have this error too when use "quasar dev" with Vite! I want to specify hostname to open the app with domain but failed: image

"App • ⚠️ Invalid host specified. No network address matches. Please specify another one."

I have the same issue, quasar dev -m capacitor -T android change my ip window, it put my wsl ip instead of ip window. I cant acces from my mobile device

amav96 commented 2 weeks ago

any solutions?