跨域资源共享CORS配置

在未对CORS进行配置时运行react项目时发现项目报错

IPFS 跨域资源共享CORS配置问题解决

为了后续的开发方便,我们还需要对跨域资源共享( CORS )进行配置,ctrl- c退出ipfs,然后按照下面的步骤进行跨域配置。

  • ctrl- c退出ipfs
  • ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
  • ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'

我在环境是window,在执行以上命令时报错,可能json格式问题:

      Error: Unknown Command "API.HTTPHeaders.Access-Control-Allow-Methods"

IPFS 跨域资源共享CORS配置问题解决

解决办法:

将上面命令修改成如下方式如:
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://example.com\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]"

相关文章:

  • 2022-02-12
  • 2022-01-04
  • 2022-01-05
  • 2021-10-20
  • 2021-12-09
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案