Use "document.baseURI" as the relative request's base URL
Current behavior
We use location.origin to be the base URL for relative requests.
https://github.com/mswjs/msw/blob/445fc63f9447df2df346c64d1a751d43b284e52a/src/utils/url/getAbsoluteUrl.ts#L10-L12
While this works, certain scenarios won't have a location set (i.e. sandboxed iframes). Relative request URL resolution would fail in those cases.
Expected behavior
Use document.baseURI instead, which is always set on the document.
I would like to jump on this and would open a PR soon.
@watife, that'd be incredible! Feel free to open the pull request, I'd be glad to help you with the code review and making this improvement happen. Let's improve the experience for developers together.
@watife @kettanaito Is this baseUrl option documented somewhere?
Hey, @athrunsun. There's no baseUrl option supported in MSW. That's an intentional decision and you can learn more about it here.
This particular change has updated an internal implementation detail to result in more reliable relative requests matching in various contexts. This is not a public, developer-facing API.