Use pdf.js cross-domain problem processing method 1

In "Using pdf.js load pdf file in a Web page" in details the basic method of use and integration of Web development pdf.js. Below showing the effect of:

Directory site is http: // localhost: 8033 / PDFTest. At this PDF file in a subdirectory on the deployment of IIS sites, access in this way everything is normal.

pdfFile = var "HTTP: // localhost: 8033 / PDFTest / Pdf / project management process groups of five and a mapping between the project management knowledge areas .pdf";

If the PDF file is located at another site, it involves the cross-domain access issues. Such as access to the PDF file located in the following IIS site

pdfFile = var "HTTP: // localhost: 7030 /5 Project management process groups and knowledge areas of project management relationship mapping .pdf";

 

Visit the following error occurs. Tip: cross-domain access is disabled.

Here are ways to solve the problem of cross-domain access.

IIS sites enable cross-domain access

1, to find the target site

2, find "HTTP response header," click to open

Right - "Add", add the following two:

Access-Control-Allow-Headers:Content-Type, api_key, Authorization 
Access-Control-Allow-Origin:*

    

After the configuration, as in FIG.

3, [Stop] the target site, the target site [START].

4, re-visit the site, PDF display normal load

If you visit or wrong, do iisreset command after clearing your browser's cache access again to normal.

Guess you like

Origin www.cnblogs.com/SavionZhang/p/11765743.html