Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

php - Swagger UI Access-Control-Allow-Origin Error

I have my Laravel PHP application where API is hosted on https://site.example.com and I have Swagger UP API Doc hosted on https://api.example.com. when I try API on Swagger API it gives Access-Control-Allow-Origin Error error. Following is my 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"
  }
}
},
}

I am not getting where to pass Access control as headers. I have tried every possible way but no success. any help would be great. Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...