how to use CORS mechanism in native client

2019-09-09 03:43发布

问题:

For example,I hava a pnacl myapp.pexe , And my website is www.A.com. and myapp.pexe and www.A.com are on the same server. However, the website www.B.com need to access the myapp.pexe. And i got a error, Native Client: access to manifest url was denied.

Using CORS can slove this problem? If using CORS can slove this problem, how to do ?

回答1:

This answer is not Native Client specific. Accessing Native Client resources from another origin uses the standard CORS mechanism.

To answer your question, though:

This can be done by setting up the correct CORS response headers on the A.com server. There are many online resources that can describe how to do this: take a look at http://www.html5rocks.com/en/tutorials/cors/ for example.

For the simplest case, the solution is to return one additional header in the GET response for myapp.pexe and myapp.nmf:

Access-Control-Allow-Origin: http://A.com

There are more headers that are required for other request method types, content types, sending credentials, etc.