0

我有一个 AngularJS 工厂,它提供了一个连接到 API 的 $resource。像这样的东西:

app.factory('Collection', function($resource, Global){

    return $resource(
        "http://:urlprefix.:network/api/v3.0/collection/:collectionId/:post/",
        {network: Global.network, collectionId: '@cid', urlprefix: '@urlprefix', post: '@post'},
        {
            'get': {
                method: 'GET',
                params: {
                    urlprefix: 'bootstrap'
                }
            },
            'post' : {
                method: 'POST',
                params: {
                    lftoken : Global.lftoken,
                    body: '@Content', 
                    urlprefix : 'quill',
                    post : 'post'
                }
            }
        }
    );  
});

我正在尝试从这样的控制器访问此 post 方法:

Collection.post({'Content', 'some content'});

或者

Collection.post({},{'Content', 'some content'});

我得到一个跨域错误:

XMLHttpRequest 无法加载 quill.xxxx.co/api/v3.0/collection/xxxx/... 请求被重定向到 'quill.xxxx.fyre.co/api/v3.0/collection/xxxx/post/.. .',这对于需要预检的跨域请求是不允许的。

但是,如果我在不传递内容的情况下这样做,只需在工厂中编写内容,它就会正确发送。

任何帮助都会很棒。

提前致谢

4

0 回答 0