简体   繁体   English

ember-cli-mirage尝试对auth0(外部)URL进行存根

[英]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. 我正在开发一个新的Ember.js项目,并使用ember-cli-mirage发出我的请求。 The project is going to use ember-simple-auth and Auth0 for user authentication. 该项目将使用ember-simple-auth和Auth0进行用户身份验证。 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: 我开始在我的项目中实施它们,但是当我尝试使用Auth0登录模式注册我的Google帐户时,在控制台中出现一个奇怪的错误:

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) (我的auth0域在上面已编辑)

I have no idea why Mirage would be trying to stub out a request to an external URL. 我不知道为什么Mirage会尝试将请求发送到外部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). 我正在阅读Mirage文档,并尝试在Mirage mirage/config.js文件中使用this.passthrough() ,因此Mirage会发出真正的请求,但这似乎没有任何效果(我猜想它仅明确适用于内部的路由配置文件中定义的namespace )。

Can anyone help me understand why this is happening and how to stop Mirage from doing it? 谁能帮助我了解为什么会这样,以及如何阻止Mirage这么做? Thank you! 谢谢!

Ember CLI Mirage intercepts all ajax ( XMLHttpRequest ) and fetch requests by default. 默认情况下,Ember CLI Mirage拦截所有 ajax( XMLHttpRequest )并fetch请求。 You have to whitelist the requests that should be passed through by using server.passthrough() method. 您必须将使用server.passthrough()方法传递的请求列入白名单。 ( 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. thismirage/config.js server实例。)您可以在server.passthrough以及所有路由处理程序中使用相对URL和绝对URL。 So server.passthrough('https://(my auth0 domain).auth0.com/userinfo') should fix your issue. 因此, server.passthrough('https://(my auth0 domain).auth0.com/userinfo')应该可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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