Skip to content

Question: What is the easiest way to deal with CORS? #56

@sporto

Description

@sporto

I have a client app in a different domain so the browser is trying to do a preflight request. e.g.

OPTIONS /accounts HTTP/1.1
Host    localhost:5000
Access-Control-Request-Method   GET
Origin  http://localhost:9000
Access-Control-Request-Headers  accept, x-requested-with
Accept  */*
Referer http://localhost:9000/
...

I would like goweb to generate the necessary response for any request coming for a particular url e.g.

Access-Control-Allow-Origin: http://localhost:9000
Access-Control-Allow-Methods: GET, POST, PUT
Access-Control-Allow-Headers: X-Custom-Header
Content-Type: text/html; charset=utf-8

Can you please give me an example on how to deal with this? Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions