Swagger UI 访问控制允许来源错误

时间:2021-01-12 12:47:47

标签: php laravel swagger-ui

我有 Laravel PHP 应用程序,其中 API 托管在 https://site.example.com 上,Swagger UP API Doc 托管在 https://api.example.com 上。当我在 Swagger API 上尝试 API 时,它给出了 Access-Control-Allow-Origin Error 错误。以下是我的 swagger.json

{
 "openapi": "3.0.0",
  "info": {
  "title": "Seller-Hub",
  "description": "",

  "license": {
  "name": "-"
  },
  "version": "1.1.0"
  },
"servers": [
 {
  "url": "https://site.example.com/public/api/v1",
   "description": "Dev server"
 },
 ],
"paths": {
"/seller": {
  "get": {
    "tags": [
      "Seller"
    ],
    "summary": "Returns Seller Data",
    "description": "Returns a map of Seller Data",
    "operationId": "seller",
    "parameters": [
    
    ],
    "responses": {
      "200": {
       "description": "successful operation",
       "headers":{
              "Access-Control-Allow-Origin":{
                "schema":{
                  "type": "string"
                  }
                },
              "Access-Control-Allow-Methods":{
                "schema":{
                  "type": "string"
                }
                },
              "Access-Control-Allow-Headers":{
                "schema":{
                  "type": "string"
                }
            },
        },
       "content": {
          "application/json": {
            "schema": {
            }
          }
        }
      },
      
    },
    "security": [
      {
         "ApiSign": []
         
      }
    ]
  }
},
"components": {   
"securitySchemes": {
  "ApiSign": {
    "type": "apiKey",
    "in": "header",
    "name": "authorization"
  }
}
},
}

我不知道在哪里将访问控制作为标头传递。我已经尝试了所有可能的方法,但没有成功。任何帮助都会很棒。谢谢

0 个答案:

没有答案
相关问题