简体   繁体   中英

ember-cli-mirage trying to stub auth0 (external) URL

I am working on a new Ember.js project and using ember-cli-mirage to stub out my requests. The project is going to use ember-simple-auth and Auth0 for user authentication. I began implementing them in my project, but I'm getting a weird error in the console when I try to sign up with my Google account using the Auth0 login modal:

Your Ember app tried to GET 'https://(my auth0 domain).auth0.com/userinfo',
but there was no route defined to handle this request.
Define a route that matches this path in your
mirage/config.js file. Did you forget to add your namespace?

(my auth0 domain redacted above)

I have no idea why Mirage would be trying to stub out a request to an external URL. I was reading the Mirage docs and tried using this.passthrough() in my mirage/config.js file so Mirage would make a real request, but that seems to have had no effect (I'm guessing it only explicitly applies to routes within a namespace defined in the config file).

Can anyone help me understand why this is happening and how to stop Mirage from doing it? Thank you!

Ember CLI Mirage intercepts all ajax ( XMLHttpRequest ) and fetch requests by default. You have to whitelist the requests that should be passed through by using server.passthrough() method. ( this is server instance in mirage/config.js .) You could use relative and absolute URLs with server.passthrough as well as with all route handlers. So server.passthrough('https://(my auth0 domain).auth0.com/userinfo') should fix your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM