urlPrefix and passthrough() are not working together
See original GitHub issueIssue type: Bug
Current Behavior: I have set up my server as below:
const server = new Server({
routes() {
this.urlPrefix = 'api';
this.get('users', () => {
return [];
});
this.get('meta-data', () => {
return {};
});
this.passthrough();
}
});
The issue is I have another library for internationalization which makes a request for a static JSON file that contains the translation data.
If I set a urlPrefix
or namespace
property of the server, it throws the error as miragejs tries to intercept that request.
Expected Behavior:
If I add the method this.passthrough()
in the routes()
it should not throw an error and miragejs should allow that request to pass through.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Passthrough for assets works only first time on page load #486
Hello, I setup passthrough for assets like this: export function ... I'm not entirely positive if our Angular integration is working yet, ...
Read more >Server - Mirage JS
You can pass a function to passthrough to do a runtime check on whether or not the request should be handled by Mirage....
Read more >vue.js - Mirage undefined error (no route defined) when ...
My problem was that my API is running on a different port than my ... By default this.passthrough() only works for requests on...
Read more >Configuration - Motion
Version 4.2 Version 4.3 Version 4.4 Current Ve...
mmalcam_control_params mmalcam_control_params mmalcam_params mmalcam...
ffmpeg_duplicate_frames ffmpeg_duplicate_frames movie_duplicate_frames movie_du...
netcam_high_params netcam_hi...
Read more >Stream | Node.js v19.3.0 Documentation
However, if calling write() is preferred, it is possible to respect backpressure and avoid memory issues using the 'drain' event: function write(data, cb)...
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
This is a sort of confusing part of the routes API but if you specify
urlPrefix
ornamespace
it applies to every route definition that follows it, and also affects calls tothis.passthrough()
.All you need to do is reset it before calling
passthrough()
and all current origin requests should start passing through:https://miragejs.com/repl/v1/311
It’s really weird. I have the same problem with transloco (Angular internationalization lib)
the i18n json files are not in the same configured prefixUrl and namespace but Mirage throw an error
Mirage: Your app tried to GET './assets/i18n/fr-FR.json?v=166783724', 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? The existing namespace is undefined
By the way, @samselikoff your solution works … but really i don’t understand why Mirage catch these routes.