Issue · GitHub
Skip to content

CORS origin not working #751

Description

@Sukii
import json
urls = (
    '/api', 'api'
)

app = web.application(urls, globals())

class api:
      def POST(self):
           web.header('Content-Type', 'application/json')
           web.header('Access-Control-Allow-Origin', 'http://localhost:80')
           data = {}
           data["foo"] ="Hello"
           return json.dumps(data)

if __name__ == "__main__":
    app.run()

I am trying to use the default 8080 port of this http://localhost:8080/api from Apache http://localhost page in port 80. However, in the response web.py is not sending 'Access-Control-Allow-Origin' to the browser and I get

Access to fetch at 'http://localhost:8080/api' from origin 'http://localhost' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions