karamokoisrael / directus-extension-flow2pdf

Other
13 stars 3 forks source link

Linking external recourses to the liquid file causes CORS issue #3

Open Abdallah-Awwad opened 3 months ago

Abdallah-Awwad commented 3 months ago

When we tried to link (for example js, css or image) files outside our domain we faced CORS issue.

For example, we wanted to add image from the local directory or from other domains we couldn't do that. The only way that worked for us is using www.my-domain.com/assets/id

Maybe we are doing something wrong, so what is the best practice in your opinion to avoid that?

Also, if you attached an example code for the liquid file in the documentation that would be great and much easier for people trying the extension.

karamokoisrael commented 3 months ago

Maybe specifying origins in the interface part can solve it. I'll see how to proceed

Natetronn commented 3 months ago

I think (I haven't tested yet) setting the CORS env vars (CORS_ORIGIN in partciular) can address external links.

Uploading the images and files to the system and then using them as if they were just normal images/files with Directus works too (when CORS_ORIGIN is set to at least true), but relative files didn't seem work, since the path was wrong in the output.

I think it has something to do with how Directus is now sandboxing extensions or how it's (or your code) is setting the paths to those files within extensions; maybe there is a better way to set the path on a per extension basis. (?)

karamokoisrael commented 3 months ago

You're right. You can also try to fix it on your side, then create a pull request.

karamokoisrael commented 2 months ago

Have you tried it with chrome in no cors mode ?