tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Cross-Origin Resource Sharing

PDF
Focus Mode
Font Size
Last updated: 2024-12-03 19:46:52

What is CORS and how do I enable it?

Cross-origin resource sharing (CORS) is to request resources over HTTP from a domain for another domain. Two origins that differ in protocol, domain name, or port are treated as different origins. To enable cross-origin access, see Setting Cross-Origin Access or the best practice documentation Setting Cross-Origin Access.

What should I do if COS denies my access request with headers in the allowlist after I configure CORS?

If your access request is denied, troubleshoot the issue as follows:
1. Check that your configuration is consistent with the headers your request includes, especially for the presence of invisible characters, such as spaces.
2. Check the domain name with which you initiate the request. If you use a CDN acceleration domain name, you need to configure CORS in the CDN console. For operation details, see HTTP Response Header.
3. Check the permissions of your bucket and determine whether your access will be granted.
4. Check if any error is reported due to your browser's cache. If such an error exists, press Ctrl + F5 to forcibly refresh your browser, or select Disable cache on the Network tab of your browser.

How do I configure the file headers in the bucket to return "Access-Control-Allow-Origin:* "?

Set the origin to * when configuring CORS. For more information, see the best practice documentation Setting Cross-Origin Access.

What should I do if the error "get ETag error, add ETag to CORS ExposeHeader setting." occurs during an upload operation?

Configure the CORS rule as shown below and try using a different browser to test whether it works. For more information, see Setting Cross-Origin Access.


What should I do if both COS and CDN are used but CORS does not work in COS?

If you are using a CDN acceleration domain name, configure CORS in the CDN console. For operation details, see HTTP Response Header.

Does CORS configuration support fuzzy match of origins?

The console supports fuzzy match of second-level domain names.

What should I do if COS CORS reports an error?

Troubleshoot the issue as follows:
1. Check that CORS rules are configured in the COS console. For operation details, see Setting Cross-Origin Access.
2. Check whether a CDN acceleration domain name is used. If yes, you need to configure CORS rules in the CDN console. For operation details, see HTTP Response Header.
3. If CORS rules are configured, check whether they are effective by running a command in the format of curl -Lvo /dev/null "<Object address>" -H "origin:<Domain name>", for example, curl -Lvo /dev/null "https://bucketname-1250000000.cos.ap-guangzhou.myqcloud.com/test.png" -H "origin:https://www.baidu.com". If the status code 200 is returned, the CORS rules are effective. In that case, clear the browser cache and try again.
4. If the problem persists, try to configure max-age=0 in the CORS rules.

Can I add IP addresses to CORS rules?

CORS rules support IP addresses. For more information, see Setting Cross-Origin Resource Sharing (CORS).

What should I do if a CORS error is reported when I use CDN to access files in COS although CDN has been configured in COS?

Enable CORS in the CDN console. For operation details, see HTTP Response Header.

What should I do if a CORS error is reported when I access file URLs?

Check whether CORS is configured properly. If yes, we recommend that you clear the browser cache and try again. If the problem persists, try to configure max-age=0 in the CORS rules. For CORS configuration details, see Setting Cross-Origin Access.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback