Passthrough for assets works only first time on page load
See original GitHub issueHello,
I setup passthrough
for assets like this:
export function startMockServer({ environment = 'test' }) {
return new Server({
environment,
urlPrefix: 'http://localhost:3000',
namespace: 'api',
routes() {
this.passthrough('http://localhost:4200/assets/**');
this.get('config', () => {
return { content: {} };
});
},
});
}
when I open http://localhost:4200
for the first time, I see all assets are loaded and Mirage reports passthrough for them as expected but if I refresh the page, Mirage shows errors that it
can’t load any of the assets:
Error retrieving icon: Mirage: Your app tried to GET 'assets/icons/menu.svg', but there was no route defined to handle this request. Define a route for this endpoint in your routes() config. Did you forget to define a namespace?
I tried to move passthrough
below mock endpoints, also moving urlPrefix
and namespace
inside routes
and configuring them after passthrough
route but got same result.
Am I configuring Mirage in a wrong way or there is an issue ?
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to make loader only run when page assets load the first ...
Try this solution,this worked for me, $(document).ready(function(){ var check=getCookie("loader"); if (check!="false") { var loader="true"; } ...
Read more >Strategies for service worker caching - Chrome Developers
Let's start with a simple caching strategy we'll call "Cache Only". It's just that: when the service worker is in control of the...
Read more >Fixing the 'cannot GET /URL' error on refresh with React ...
The first time a user loads your app (i.e., visits your website), they don't have any JavaScript loaded. That means no React and...
Read more >Button UI Not Working with The new Input system - Unity Forum
I am working on my first serious 2d afterwork unity project. ... Now I just load one scene at a time (no in-game...
Read more >How To Use Preload and Prefetch in HTML to Load Assets
By setting the rel attribute to stylesheet in onload , the browser is told to use the resource. Since it's been already downloaded...
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 FreeTop 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
Top GitHub Comments
After quite a bit of debugging I still wasn’t able to figure out why that issue happens in my project but fortunately I found out that you can pass a function to
passthrough
and solved it for me and now it works as expected every time:@samselikoff thanks for you reply. Unfortunately, I can’t reproduce this issue when I setup a small project, even though, I did all steps that are in my actual project and everything works as expected every time. My actual project is private, unfortunately I can’t share it. Do you have some tips/ideas what could possibly change behavior of Mirage ? Yes, I use latest
0.1.40
version. Thanks