javascript - Angular ng-token-auth,发布到错误的本地主机

标签 javascript ruby-on-rails angularjs ruby-on-rails-4

我有一个在 http://localhost:3000/ 上运行的 Rails API ,以及运行在 http://localhost:8000/ 上的 Angular 前端。我正在使用 ng-token-auth 实现登录功能。它将 token 发布到错误的本地主机,如下所示:

http://localhost:8000/api/auth/sign_in

我已经发现如何更改 URL 的每个部分,除了“http://localhost:8000/ ”,它需要是“http://localhost:3000/ ”,任何人都可以提示我如何做到这一点吗?

提前致谢。

最佳答案

来自documentation ,您应该将 url 放入配置中:

angular.module('myApp', ['ng-token-auth'])
    .config(function($authProvider) {
        $authProvider.configure({
            apiUrl: 'http://localhost:3000'
        });
    });

关于javascript - Angular ng-token-auth,发布到错误的本地主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37571406/

相关文章:

html - Rails 上的 SASS 无效 CSS 错误

ruby-on-rails - Rails 生产中缺少 secret_key_base

javascript - 通过下拉菜单在数组之间切换需要相当多的时间。我该如何减少它? Angularjs、IvhTreeview

javascript - 将 JavaScript 导入到 Angular2

javascript - 如何检查浏览器是否支持HTML5?

javascript - 获取 JSON 输入并将其存储到数组中 (javascript)

ruby-on-rails - Rails 中 form_for 中的附加参数

angularjs - 错误 : [$resource:badcfg] Error in resource configuration. 预期响应包含一个数组但得到一个对象

angularjs - 为什么 Controller 对路线更新没有响应?

javascript - 未捕获的类型错误 : Cannot read property 'data' of undefined with Gatsby and graphQl