ember-cli-mirage 试图存根 auth0(外部)URL

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

我正在开发一个新的 Ember.js 项目并使用 ember-cli-mirage 来消除我的请求。该项目将使用 ember-simple-auth 和 Auth0 进行用户身份验证。我开始在我的项目中实施它们,但是当我尝试使用 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?

(我的 auth0 域已在上面编辑)

我不知道为什么 Mirage 会尝试将请求存根到外部 URL。我正在阅读 Mirage 文档并尝试在我的 mirage/config.js 文件中使用 this.passthrough() 这样 Mirage 就会发出真正的请求,但这似乎没有效果(我猜它只明确适用于内部的路由在配置文件中定义的 namespace

任何人都可以帮助我理解为什么会发生这种情况以及如何阻止 Mirage 这样做吗?谢谢!

Ember CLI Mirage 默认拦截 all ajax (XMLHttpRequest) 和 fetch 请求。您必须使用 server.passthrough() 方法将应通过的请求列入白名单。 (thismirage/config.js 中的 server 实例。)您可以将相对和绝对 URL 与 server.passthrough 以及所有路由处理程序一起使用。所以 server.passthrough('https://(my auth0 domain).auth0.com/userinfo') 应该可以解决您的问题。