question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with domains in 'baseUrl' having several dots

See original GitHub issue

Current behavior:

I’m trying to tests a website on an Azure domain which looks like:

http://my-test-app.westeurope.cloudapp.azure.com

When I try to run cypress, I’m getting the following error:

Uncaught DOMException: Failed to set the 'domain' property on 'Document': 'azure.com' is not a suffix of 'localhost'.

If I try to run cypress run, my terminal just hangs after (Tests Starting) without stopping or showing any error.

Desired behavior:

The site is testable.

Steps to reproduce:

See above.

Versions

2.1.0

Also, it seems to be a recent regression, I was able to test this website a few months ago.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
antezeceviccommented, Feb 12, 2020

Hi @jennifer-shehane ,

This still doesn’t work in Cypress 4.0.1. I checked it in 3.8.3 and 4.0.1, and base url is completely ignored if you have more than one dot anywhere in the url.

For example, we have urls like this: _https://sub.domain.com/MyApp-v1.2.3/appArea/_ (notice the multiple dots in the app name)

If I call cy.visit("https://sub.domain.com/MyApp-v1.2.3/appArea/") everything is fine, but if I use the recommended approach with baseUrl set in cypress.json like this cy.visit("MyApp-v1.2.3/appArea/"), the cypress will ignore the base URL and will navigate to: http://MyApp-v1.2.3/appArea/

The original question had dots in the baseUrl, and we have the dots in the app name, so this could affect a lot of apps potentially.

Quick fix for this is to URL encode the dots, which means that regular expression that concatenates the baseUrl with app name has a bug. The problem with URL encode is that the asserts and logs in cypress contain the URL encoded text then, so it looks ugly.

I think this should still be treated as a bug.

Thanks!

0reactions
HallOfSamecommented, Nov 8, 2022

Running in to this issue in v10.7 and 10.11 as well.

From what I can tell it requires both:

  • Manually setting port in the configuration
  • Setting the baseUrl inside of setupNodeEvents

Example configuration file:

const { defineConfig } = require("cypress");

const exampleBaseUrl = "https://localhost.someDomain.com:3001/";

module.exports = defineConfig({
  e2e: {
    setupNodeEvents(on, config) {
      config.baseUrl = exampleBaseUrl;

      return config;
    },
    // Uncomment the line below and the test loads properly
    // baseUrl: exampleBaseUrl
  },
  // Removing the port setting also fixes the issue
  port: 3000
});

Full minimal reproduction in this repo here: https://github.com/HallOfSame/CypressBaseUrlBug

The error is thrown from the configure method in packages/driver/src/cypress.ts.

    if (domainName && config.testingType === 'e2e') {
      document.domain = domainName
    }

When baseUrl is set inside of setupNodeEvents the existing document.domain here is localhost. Moving the baseUrl definition out of the setup method causes document.domain to be localhost.someDomain.com instead, fixing the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

asp dot net web config key Base URL issue - Stack Overflow
I got an issue during test my asp dot net web based application. In the Page there is an "Slip button" and when...
Read more >
Is using dots in URL path really a problem? | SEO Forum - Moz
we have a couple of pages displaying a dot in the URL path like domain.com/mr.smith/widget-mr.smith It displays fine in chrome, firefox and IE...
Read more >
The Document Base URL element - HTML - MDN Web Docs
The HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in...
Read more >
FAQ - Using Relative Links - Zoom Search Engine
In Spider Mode, you should not change the Base URL to a relative path. This is because the Base URL is required to...
Read more >
GitLab Pages domain names, URLs, and base URLs
The baseurl option might be named differently in some static site generators. Every Static Site Generator (SSG) default configuration expects to find your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found