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

CORS header not being set #61

Open
AlasdairGray opened this issue Dec 18, 2018 · 2 comments
Open

CORS header not being set #61

AlasdairGray opened this issue Dec 18, 2018 · 2 comments
Labels

Comments

@AlasdairGray
Copy link
Member

This issue was discovered when adding JSON-LD support to the validation and is captured in issue ShEx-Validator #36.

To reproduce the error, deploy Validata with the Bioschems configuration file, or use the deployment at http://www.macs.hw.ac.uk/~ajg33/BioschemasValidata/

Click on one of the examples which will add JSON-LD into the Input Data box. Validata should convert this into turtle for validation. If you look in the error console you will see
Access to XMLHttpRequest at 'http://schema.org/' from origin 'http://www.macs.hw.ac.uk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

What is going on is that when the Input Data box detects that the input is JSON-LD it tries to covert it to turtle. You can see this by entering the following

{
    "@type": "http://schema.org/Person",
    "name": "Jane Doe"
}

If you try the equivalent with an @context statement, then the system tries to pull in the context file dynamically. This fails with the CORS error

{
    "@context": "http://schema.org/",
    "@type": "http://schema.org/Person",
    "name": "Jane Doe"
  }

I have verified that schema.org is able to server the request properly. It is something in the request that is incorrect. I just can’t work out what.

@kcmcleod
Copy link

The CORS statement normally goes in the response header from the server and allows the data served to be used by applications from other sites.

Access to XMLHttpRequest at 'http://schema.org/' from origin 'http://www.macs.hw.ac.uk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Reading the error it looks as though the server (http://schema.org) has no CORS statement in its response header. If this is true, it is a schema.org issue and not a Validator one.

The only to tell is to look at the response header. What is the URI that is being called?

@AlasdairGray
Copy link
Member Author

There is something in the way that schema.org is set up that requires the client to send certain things in the header. There are some details at https://github.com/json-ld/json-ld.org/wiki/existing-contexts

When I use the Chrome CORS extension to inject the appropriate incantations it works. Just need to work out how to get the jQuery to inject them.

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

No branches or pull requests

2 participants