小编ano*_*oop的帖子

CORS预检错误redux和loopback API

我在react-redux&API app上有一个客户端应用程序loopback.

对于我的本地测试,我在端口8080上运行客户端应用程序,在端口3000上运行服务器应用程序

当我尝试使用loopback-passport component客户端应用测试Google OAuth(使用)时,我收到以下错误.

在此输入图像描述

当我使用POSTMAN测试它时,没有问题.

这是客户端代码,

require('babel-polyfill'); 
import { CALL_API } from 'redux-api-middleware'; 
import C from '../constants';
const API_ROOT = 'http://localhost:3000';
function googleLogin() {   return async(dispatch) => {
    const actionResp = await dispatch({
      [CALL_API]: {
        endpoint: API_ROOT + '/auth/google',
        headers: {
          'Access-Control-Allow-Credentials': 'false',
          'Access-Control-Allow-Methods': 'GET',
          'Access-Control-Allow-Origin': API_ROOT
        },
        method: 'GET',
        types: ['GET', 'GET_SUCCESS', 'GET_FAILED']
      }
    });

    if (actionResp.error) {
      console.log(actionResp);
      throw new Error('Some error in communication', actionResp);
    } else {
      console.log(actionResp);
    } …
Run Code Online (Sandbox Code Playgroud)

javascript cors reactjs loopbackjs redux

6
推荐指数
1
解决办法
994
查看次数

导入的ESLint规则错误

我通过eslint得到以下错误.

我也在文件中添加ecmaFeatures: { "modules": true }.eslintrc.

在此输入图像描述

ecmascript-6 eslint atom-editor

1
推荐指数
1
解决办法
3137
查看次数