Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of CORS protocol #644

Open
8 tasks done
gschwind opened this issue Feb 11, 2022 · 1 comment
Open
8 tasks done

Add support of CORS protocol #644

gschwind opened this issue Feb 11, 2022 · 1 comment

Comments

@gschwind
Copy link
Collaborator

Description

The CORS protocol [1] is needed to support request from web browser from cross-origin fetch, i.e. fetch from different domain name. As instance a javascript from domain1.com that want to fetch a WPS from domain2.com. The protocol need to answer to some HTTP OPTIONS requests.

In my case I override the wsgi application when OPTIONS request is perfomed to allow any cross-origin request as follow:

from werkzeug.wrappers import Request, Response
from pywps.app.Service import Service


_servive = Service(processes, ['PWD/pywps.cfg'])

@Request.application
def application(http_request):
    # Allow request from any sources to avoid cross-origin issue.
    if http_request.method == 'OPTIONS':
        return Response(headers={
            "Access-Control-Allow-Origin": "*",
            "Access-Control-Allow-Headers": "origin, content-type, x-requested-with",
            "Access-Control-Allow-Methods": "PUT, GET, POST, DELETE, OPTIONS"
        })

    # Default case
    r = _servive.call(http_request)
    return r

[1] https://fetch.spec.whatwg.org/#cors-protocol

Environment

  • operating system:
    Any

  • Python version:
    Any

  • PyWPS version:
    Any

  • source/distribution

  • git clone

  • Debian

  • PyPI

  • zip/tar.gz

  • other (please specify):
    Any

  • web server

  • Apache/mod_wsgi

  • CGI

  • other (please specify):
    Any

Steps to Reproduce

Additional Information

@cehbrecht
Copy link
Collaborator

cehbrecht commented Mar 15, 2022

Just adding a link to ogcapi docs about CORS:
https://docs.ogc.org/is/18-062r2/18-062r2.html#toc27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants