Skip to content

Option to Prevent Trailing Slash on baseUrl in Cypress Config #31600

@josefnorlin-svt

Description

@josefnorlin-svt

What would you like?

A property in the cypress.config.ts file to lock the baseUrl so that Cypress does not add an extra / at the end.

Why is this needed?

Relating to #5269 we too face the same problem. In our case, we're using HashRouter in React and need to set the baseUrl like this:
https://domain.com/index.html#specific_route

As @dialex mentioned, Cypress automatically appends a trailing slash (/) to the baseUrl, which results in:
https://domain.com/index.html/**/**#specific_route
instead of the desired:
https://domain.com/index.html#specific_route

This causes all of our tests to fail.

Since setting a global baseUrl is considered best practice in Cypress, it's frustrating to have to work around this by using an environment variable instead.
For us, @dialex, and others facing the same issue, adding an option in cypress.config.ts to prevent Cypress from automatically adding a trailing slash to the baseUrl would be a great solution.
For example, a property like lockBaseUrl: true could be introduced to preserve the exact baseUrl as defined.

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions