⚠️ CORS 跨域問題解決方案
如果遇到 CORS 錯誤,請選擇以下任一方式:
- 方案 1 (推薦): 在你的 ASP.NET Core API 專案中加入 CORS 設定
- 方案 2: 使用本地伺服器開啟此檔案 (例如: python -m http.server 8000)
- 方案 3: 使用瀏覽器擴充功能暫時停用 CORS (僅供測試)
💡 ASP.NET Core CORS 設定範例
在 Program.cs 加入:
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAll", policy =>
{
policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
});
});
app.UseCors("AllowAll");
HTTP 方法
驗證 (Authentication)
Headers (請求標頭)
狀態碼:
狀態文字:
回應時間: ms
回應內容:
💡 cURL 命令 (可在 CMD 中執行以繞過 CORS)