-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 authentication not enabled #255
Comments
Authentication credentials may also be required in function makeImage. Additionally we had to add ... See "MDN: Allowing cross-origin use of images and canvas" . Sending (existing) credentials for authentication of external URI (CORS) requests should be configurable. Requirement: The remote webserver hosting the images/resources has to respond with appropriate CORS headers to let the browser know that the cross domain request from that origin is safe/allowed. I will provide a patch on my own fork if I find time... |
…of external URI (CORS) requests.
Excellent change. It turns my hack into real code. Thanks. Alas, my situation became more complex. When only some resource servers require authentication 'use-credentials' must be not only configurable but also conditional. I my case the map server requires authentication but the photo server does not. The server urls are distinct, so I ended up enclosing 'use-credentials' with if (url.search(new RegExp("api", "i")) > 0) A generic solution for that situation will be much more difficult. |
… URI (CORS) requests. Cherry picked from iqdoq-dfischer@2bae568 Resolves tsayen#255
* toCanvas returns a promise that is fulfilled with a canvas object. * ignore image with invalid src * Prepare for new package name. Adds Chrome fix to copy over the font when cloning. Adds scaling up the image to reduce blur. * Force-passed some tests that no longer work Made scale an option so tests can pass (defaults to 1) Fixed errors looking at external style-sheet rules. For now, don't test Firefox, don't check rendered canvas ::before ::after content, don't expect access to external sheets. * Fix badge * Bump release to 2.7.1 * 2.7.2 * Moving repository to 1904labs organization 2.7.3 * Fix JSFiddle link in issue template * Removed and excluded node_modules * Upgrade all packages. Fix all audit fails * 2.7.4 Bump version * Updating travis for node 8 * Allow text rendering test to run a bit longer * Optionally send (existing) credentials for authentication of external URI (CORS) requests. Cherry picked from iqdoq-dfischer@2bae568 Resolves tsayen#255 * Release 2.7.5 Includes ability to pass authentication on for CORS * fix export of 0 size canvas elements #3 fix for 1904labs#3 * Add tests and prepare release * 2.7.6 * Fix bower version * Update dev dependencies and fix test * Release 2.7.7 Upgrades all devDependencies and fixes unit test. * Extend timeout for image rendering test. * FIX: File extension error when URL has query parameters When a URL pattern has a query string the file-extension isn't matched correctly IFF the URL has . in the query parameters. This fix is from original dom-to-image repo by: https://github.com/CG-man tsayen#285 * Prepare for 2.8.0 release * fix font mangling * restore dist * remove postbuild * fix getCssRules * 1904labs > tsayen * revert * revert * yarn.lock Co-authored-by: Andreas Girgensohn <[email protected]> Co-authored-by: ioslh <[email protected]> Co-authored-by: Marc Brooks <[email protected]> Co-authored-by: Aidas Klimas <[email protected]> Co-authored-by: Adrien Pyke <[email protected]>
Fixing following issue: CORS authentication not enabled #255 tsayen/dom-to-image#255
@iqdoq-dfischer - I have added the line that you have proposed:
I obviously don't have access to the maps.stamen.com server and I still get the CORS error when trying to save a Leaflet map using dom-to-image. Oddly don't have this issue at all in Firefox which suggests it's a (recent) Chrome limitation. Do you have any suggestions? See also stamen/maps.stamen.com#158 |
What is the chance of getting If I do a fork, implement the change and create a PR. Is there any chance it would be approved and added to the release? |
Use case: description, code
Print with easyprint a react leaflet map from a server requiring authentication
Expected behavior
Pass authentication token to map server
Actual behavior (stack traces, console logs etc)
CORS request refused
Code change required
Add:
request.withCredentials = true;
at line 476
Browsers
The text was updated successfully, but these errors were encountered: