Bug: Polly does not respect <base> tag
See original GitHub issuePrerequisites
A website running under a certain path e.g. “http://localhost:4200/some/feature”
Description
XHR requests made to a relative url, e.g. “rest/my-api” are altered by PollyJS to contain parts of the browser url. In this example “/some/rest/my-api”.
Config
Polly.register(XHRAdapter);
Polly.register(PersisterStub);
const polly = new Polly('mock', {
adapters: ['xhr'],
persister: 'PersisterStub'
});
const { server } = polly;
server.get().passthrough();
Dependencies
{
"@pollyjs/adapter-xhr": "~4.0.2",
"@pollyjs/core": "~4.0.2",
"@pollyjs/persister-rest": "~4.0.2",
}
Relevant Links
https://github.com/nbfr/pollyjs-dream-app
You can run the app with “npm run start” to run without PollyJS or “npm run start-mock” to run with PollyJS. Then open http://localhost:4200/some/feature.
Then check the network traffic. The client will send a request to “rest/my-api” which is changed by PollyJS to “some/rest/my-api”.
Environment
Node.JS v10.16.3 win32 10.0.1832 npm 6.9.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
not respect <base > tag · Issue #1426 · vuejs/vue-router - GitHub
What is actually happening? vue-router can't parse base url. This example is from the html spec about base tag https://html.spec ...
Read more >Why base tag does not work for relative paths? - Stack Overflow
Something doesn't make sense here. Although paths starting with / are absolute, URLs containing such paths are actually called relative URLs.
Read more >Best practices with HttpClient and Retry Policies with Polly in ...
Create a Retry Policy from the base PolicyBuilder. Here we are! let's see how we are using configuration that we defined before to...
Read more >25090 - BASE tag ignored if original page URL contains http ...
the original source URL contains the BASE HREF URL as a substring. ... it works fine, no bug. ... then it's buggy and...
Read more >Essentials - Julia Documentation
The behaviors of Base and standard libraries are stable as defined in SemVer only if they are documented; i.e., included in the Julia...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jasonmit : Thank you for quick feedback and the work around. For now I decided to extend the existing XHRAdapter.
Okay, I believe this is caused by Polly not respecting the
<base href="/">
in your template when building the request URL.For now, a work around like this should unblock you: