Skip to content

Requested URL is always an absolute URL #356

@robinborst95

Description

@robinborst95

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, '');

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions