Update README.md

This commit is contained in:
Brandon Liu
2022-10-26 17:49:15 +08:00
committed by GitHub
parent 10e24d9437
commit d01057b1d6

View File

@@ -60,10 +60,39 @@ Reading a PMTiles archive from cloud storage requires [CORS](https://developer.m
```json ```json
[ [
{ {
"origin": ["*","example.com"], "origin": ["example.com","*"],
"method": ["GET","HEAD"], "method": ["GET","HEAD"],
"responseHeader": ["range","etag"], "responseHeader": ["range","etag"],
"maxAgeSeconds": 3000 "maxAgeSeconds": 3000
} }
] ]
``` ```
### Setting CORS from the command line
[AWS CLI](https://aws.amazon.com/cli/) is the recommended way to do this:
create a file `cors_rules.json`:
```json
{
"CORSRules": [
{
"AllowedOrigins": ["example.com","*"],
"AllowedHeaders": ["range"],
"AllowedMethods": ["GET","HEAD"],
"MaxAgeSeconds": 3000,
"ExposeHeaders": ["ETag"]
}
]
}
```
Then configure your bucket with:
```sh
aws s3api put-bucket-cors --bucket MY_BUCKET --cors-configuration file:///home/user/cors_rules.json
```
Optional arguments:
* `-endpoint-url https://S3_COMPATIBLE_ENDPOINT`: for non-S3 storages.
* `--profile PROFILE`: choose credentials named in `~/.aws/credentials`