无法将 http://localhost 添加到 DigitalOcean Spaces CORS 规则

问题描述 投票:0回答:3

从图中可以看出,当前无法添加

http://localhost
作为 CORS 规则。

cors digital-ocean digital-ocean-spaces
3个回答
5
投票

为了解决此问题,您必须使用s3cmd等工具。使用此工具的最简单方法是下载源代码。如果您已经安装了 Python,则可以使用以下命令更改 DigitalOcean Spaces CORS 配置(需要 python 2.7 或更高版本):

注意:您可能还需要安装Gpg4win

首先从这里下载源代码并解压到任意目录中。然后在该目录中运行以下commands

。您还应该将您的 
cors.xml
 配置放入此目录中。

python s3cmd --configure


这是阿姆斯特丹 3 上托管的配置的示例输入....

Access Key [YOUR_ACCESS_KEY]: Secret Key [YOUR_SECRET_KEY]: S3 Endpoint [ams3.digitaloceanspaces.com] DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.ams3.digitaloceanspaces.com]: Encryption password [password]:

python s3cmd ls

 - 查看您的所有空间

python s3cmd setcors cors.xml s3://your-space-name-here

,其中 
cors.xml
 是工作目录中的一个文件,其中包含标准 cors 配置,例如:

<CORSConfiguration> <CORSRule> <AllowedOrigin>http://localhost:4000</AllowedOrigin> <AllowedMethod>GET</AllowedMethod> <AllowedMethod>HEAD</AllowedMethod> </CORSRule> </CORSConfiguration>
运行最后一个命令后,您现在应该在 DigitalOcean 仪表板中看到您原来的 CORS 配置现已替换为您保存到的任何配置 

cors.xml


    


0
投票
另一个选项是向本地主机文件添加一个条目

127.0.0.1 local.test.com

而不是:

本地主机

用途:

local.test.com


0
投票
更新,数字海洋目前支持本地主机。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.