kleisauke / wasm-vips

libvips for the browser and Node.js, compiled to WebAssembly with Emscripten.
https://kleisauke.github.io/wasm-vips/
MIT License
519 stars 26 forks source link

[Question] How do you deal with CDNs and Vite #67

Closed Eptagone closed 5 months ago

Eptagone commented 7 months ago

Hi. I have the following situation. I'm working with an admin panel. Some images and scripts come from an external CDN. The main project is not a NodeJS app. I use Vite as a bundler for CSS and some scripts.

I want to use this library to crop images, generate webp and thumbnails on client side but when I add the required headers for cross-origin isolation, all the images and scripts from the CDN stop working. The same happen with my assets from my local Vite Dev Server.

I am currently still looking for a solution to this and I would be very grateful if you know of any strategies, tricks or anything you can share to solve this problem.

kleisauke commented 7 months ago

You can set the COEP header to credentialless to allow loading of cross-origin resources that are not served with CORS or with the Cross-Origin-Resource-Policy (CORP) header.

Cross-Origin-Embedder-Policy: credentialless

See https://developer.chrome.com/blog/coep-credentialless-origin-trial/ for more information.

There's only one caveat; this is not supported in Safari.

Eptagone commented 7 months ago

It works! Thanks. Mmm, Safari... Well, at least it's something.