sayanee / angularjs-pdf

:page_facing_up: An AngularJS directive <ng-pdf> to display PDF files with PDFJS
http://sayan.ee/angularjs-pdf/
MIT License
494 stars 248 forks source link

Cross origin request with url and not with another #193

Closed LucieLeneveu closed 7 years ago

LucieLeneveu commented 7 years ago

Hi,

I tried to use this url : https://docupub.com/docs/7a71fdf4-bd66-4acf-8a8c-a8d1c9897967/TEST_DSI.pdf with ng-pdf but i have a cross origin request. and a proxy authentication required

So, I tried with another url : https://s3-us-west-2.amazonaws.com/s.cdpn.io/149125/relativity.pdf and it's work perfectly.

So i would like to understand why the first url don't work and what the second work.

Someone could help, please ?

And sorry for my bad english.

dennybiasiolli commented 7 years ago

Hi @LucieLeneveu , it seems a server side problem.

You must use CORS in your server side for all requests in docpub.com.

https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

I hope this help you!

Cheers

LucieLeneveu commented 7 years ago

Can you give me an example, please ?

I tried to add <VirtualHost *:80> ServerName url-serv <Directory **> Header set Access-Control-Allow-Origin "" Header set Access-Control-Allow-Methods "*" Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding" in my httpd.conf but i couldn't restart apache after.

Also, i tried to use .config(function($httpProvider) { $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; }); and other solutions i've found but they don't worked.

simobasso commented 7 years ago

Please follow this guide: https://enable-cors.org/server_apache.html

Il ven 2 giu 2017, 10:24 LucieLeneveu notifications@github.com ha scritto:

Can you give me an example, please ?

I tried to add <VirtualHost :80> ServerName url-serv <Directory

> Header set Access-Control-Allow-Origin "" Header set Access-Control-Allow-Methods "" Header set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"

in my httpd.conf but i couldn't restart apache after.

Also, i tried to use .config(function($httpProvider) { $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; }); and other solutions i've found but they don't worked.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sayanee/angularjs-pdf/issues/193#issuecomment-305723146, or mute the thread https://github.com/notifications/unsubscribe-auth/AEAgdvu9SKPUw_Gy6icn1p3uu4yOZ0SMks5r_8bBgaJpZM4Ns-g3 .