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
passthrough not really working as expected #1072
Comments
I have not had to write a pretender passthru for other URLs, so no experience, sorry, perhaps someone else has? Since this repo is using Pretender and pretender is not performing passthru as expected, it would seem this is more an issue for the PretenderJS library (https://github.com/pretenderjs/pretender#pass-through) Here is some comments in the MirageJS code that talks about passthru https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L391. It looks like while calling the passthru the _getFullPath is being applied https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L464, maybe you need to set urlPrefix and namespace to undefined first looking at the fullPath code https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L479 |
The only thing i saw was this logline: https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L309-L310 |
I can confirm this issue was about the missing namespace :( Thanks Brian! |
So it lets passthrough the call, but its not actually returning the data using fetch/axios. Which makes the setup unusable when you want to go slowly from a complete mock to a working api application. I guess that should be documented somewhere @cah-brian-gantzler ? |
When a package is using another package, its really hard to determine what should be documented where. Since the passthru is just calling the pretender passthru, then any issues or nuances should really be documented in pretender. |
It is really scary to see that mirage.js is being built over an unmaintained package like pretender.js. And the interesting thing is that pretender.js is quite small, just a few files. What is the sense is having a behavior that we need to map all request domains to ensure that they do not break? It should be the opposite. Mirage.js should ensure that all requests pass, except for those that we explicitly mock. We have a use case that our BE is till being architected and we want to start working on UI. But our app is built over a complex infra and many underlying requests are made to different apis / vendors. I have tried it out and could not get it through. Then when I though about the headache in maintaining this while the prototyping phase is done I had to give up. Is it on the roadmap to abandon pretender.js? If not, I guess that the foundations of this initiative might be on the wrong direction. |
Hi @IanVS . I have opted in using MSW, just in our testing/staging env. Not registering msw in production. It works pretty well, for our needs on this phase. But I guess that with some tweaks to mimic some real network behavior for rest api calls, I guess that I would prefer a solution to not rely on service workers, as they are very fragile, as they are restricted by browsers on different conditions (anonymous tabs, etc, vendors, etc). Of course, for prototyping, we could assume that this issue is not the end of the world, but it limits testing the FE features in diversified browsers, etc. The tradeoff is still positive, imho. |
@alioshr thanks for the update. Are you using MSW together with mirage, or on its own? I've hit my own passthrough error in pretender just now, so I might be following in your footsteps. |
Hi, i understand MirageJS uses Pretender globally which means it basically takes over fetch. But i assumed the passtrough option described here https://miragejs.com/api/classes/server/#passthrough would actually allow other urls to work. Which they don't, the only thing this feature seems to do is to not throw any error.
How can you allow some urls to work? Because i just used it to first create the app without any backend and slowly allow created backend api endpoints to work, by removing them from the mock. But now its an all or nothing implementation ...
Isn't it an idea to let passtrough values use the real fetch?
The text was updated successfully, but these errors were encountered: