Skip to Content
🚀 Drubase One v1.1 - 基于 Drupal 11 的多租户后端即服务平台
Docs配置CORS 跨域

CORS 跨域配置

Drubase One 使用 Drupal 11 的标准 CORS 配置方式。

📝 配置方式

配置文件位置

编辑 web/sites/default/services.yml 文件:

parameters: cors.config: enabled: true allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With'] allowedMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'] allowedOrigins: ['http://localhost:3000', 'https://app.example.com'] allowedOriginsPatterns: [] exposedHeaders: ['Content-Type', 'Authorization'] maxAge: 3600 supportsCredentials: true

⚠️ 注意:

  • 如果 services.yml 不存在,复制 default.services.yml 并重命名
  • 修改后需要清除缓存: docker exec php8-4-fpm sh -c "cd /var/www/html && vendor/bin/drush cr"

📖 详细配置

关于 CORS 配置的完整参数说明和高级用法,请参考:

⚠️ 安全提示

生产环境配置建议:

  • ❌ 不要使用通配符 allowedOrigins: ['*']
  • ✅ 明确指定允许的域名 allowedOrigins: ['https://app.example.com']
  • ✅ 只使用 HTTPS 域名
  • ✅ 启用凭证时必须指定具体域名(不能用通配符)

📖 相关资源

Last updated on