Skip to content
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

Requested URL is always an absolute URL #356

Open
robinborst95 opened this issue Oct 2, 2023 · 0 comments
Open

Requested URL is always an absolute URL #356

robinborst95 opened this issue Oct 2, 2023 · 0 comments

Comments

@robinborst95
Copy link

In #151, a change was made that adds the current origin to the baseUrl. Although this works fine in most cases, or as the PR says "unlikely to be an issue in practice", it does affect our tests. Let me briefly explain this first.

Our acceptance tests work with PollyJS, which stores the API responses in recording files. To make those requests in the recordings API-agnostic (to allow recording tests with different backends), we set up our API host as '' and use a proxy server to intercept those requests and do the requests to the backend that is currently configured. The way the tests then look up the requests in those recording files, is based on the url, headers, etc. Since this addon turns a url like /v1/users into for example http://localhost:4200/v1/users, this lookup fails. Re-recording the tests is not a solution though, as CI uses a different host and then the lookup would fail there.

I think that the location.href addition was done because new URL(baseUrl) fails with a baseUrl of e.g. /v1/users. However, since this is indeed a breaking change (for us at least), I think it's safer to do something like

return baseUrl.startsWith(url.origin) ? url.href : url.href.replace(url.origin, '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant