New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a subdomain with localhost will throw an error of unreachable on Mac #1488
Comments
@OrganicCat If my understanding is correct, you can't access a subdomain on localhost without it being added to your hosts file. This is true for any browser, Cypress driven or not. Could you explain your desired behavior in this case for Cypress vs a typical web browser accessing localhost subdomains? - |
This is not true for a webpack build set up like so: devServer: {
historyApiFallback: true,
allowedHosts: ['.localhost']
} This requires no additional setup in my hosts file, which is good because our program requires us to set up a lot of dynamic subdomains. Now if this were deployed in a remote location, yes that would require additional setup. But locally, no. Additionally, if this is going to be classified as a feature, please at least add warning info if someone is attempting this, or notes or something, because right now cypress doesn't work with no useful information given. |
I have the same problem, trying to open http://booking.localhost:8080 results in:
I can open this page in any browser without problems. |
exact same problem here |
Sure we can look into adding this. @bkucera is right that I don't believe this works by default - when the DNS queries come back - it will not be your machine, but we can add overrides to automatically do this. BTW there is an undocumented option called // cypress.json
"hosts": {
"*.localhost": "127.0.0.1"
} I haven't tried this but our e2e tests do something similar and you could do a quick search in our repo for various implementations. Here's one example: https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress.json#L4 |
works like a charm, thanks for the quick answer @brian-mann! |
Add the hosts config option, from cypress-io/cypress#1488 (comment) to the cypress config so we can access *.locahost. Then use those in the cobrand tests, as well as allowing them as cobrands by default in the FixMyStreet server setup. NB: need to set fixmystreet.localhost as the FixMyStreet BASE_URL otherwise form submissions can go to localhost and then you get a cypress cross origin security error.
Add the hosts config option, from cypress-io/cypress#1488 (comment) to the cypress config so we can access *.locahost. Then use those in the cobrand tests, as well as allowing them as cobrands by default in the FixMyStreet server setup. NB: need to set fixmystreet.localhost as the FixMyStreet BASE_URL otherwise form submissions can go to localhost and then you get a cypress cross origin security error.
Add the hosts config option, from cypress-io/cypress#1488 (comment) to the cypress config so we can access *.locahost. Then use those in the cobrand tests, as well as allowing them as cobrands by default in the FixMyStreet server setup. NB: need to set fixmystreet.localhost as the FixMyStreet BASE_URL otherwise form submissions can go to localhost and then you get a cypress cross origin security error.
Closing as resolved. |
Current behavior:
If you set up a visit call to go to something like mysubdomain.localhost:4200 Cypress will not respond properly (and will not visit) because it uses the hosts file for some subdomain redirection on localhost.
Desired behavior:
I shouldn't have to add 127.0.0.1 for EVERY subdomain I want to test on my localhost, especially if I generate these for tests. Cypress should not have to rely on the hosts file for this.
How to reproduce:
Create a server that runs on a subdomain and your local machine so the address is something like mysubdomain.localhost:4200. Attempt to run a test that goes there. It will fail unless you add
127.0.0.1 mysubdomain.localhost
to your hosts file on Mac
The text was updated successfully, but these errors were encountered: