-
|
I am using the API to get the content of a note (I have tried both a shared note and non-shared note) and trying to load the content onto a my own HTML page within sveltekit. The HTML and everything works great (albeit more API calls then I would like) but I am running into an issue with the attachments/images. // Fix relative image src paths by prepending full base URL
content = content.replace(
/src="api\/attachments\//g,
`src="${baseUrl}share/api/attachments/`
);this updated the attachment src to be changed from a relative/local one to a full url, as well as adds the when I use this URL in a browser manually it works fine and the Trilium share page works fine. However, when I try to place it into an IMG on my own site I get or I get this if I manually change the html in the browser to the address. I have updated the config/environment variables with the CORSALLOWORIGIN but it still doesn't appear to work, I used * for testing purposes. I would not use a wildcard for production. config.ini Is there something I am missing specifically for attachments that will allow me to use the images on the mydomain.com from my Trilium hosted on subdomain.mydomain.com. As note I am using a cloudflare tunnel, however I also tried this using the internal |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Hi @lzinga! I'm Dosu and I’m helping the Trilium team. Trilium sets CORS headers globally for all endpoints, including attachments, using the values from your environment variables or config.ini—so your settings should work for images as well as API requests. If you’re still getting CORS errors or 403s, it’s likely due to one of these issues:
To debug:
If the CORS headers are present and correct, but you still get a 403, it’s almost certainly an access or proxy issue, not a Trilium CORS config problem. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
So when I do which I believe this issue may be happening due to the crossorigin opener/resource policy being same-origin. However I am not seeing how these are being set in the code, if at all. You could probably overwrite these in a nginx settings, but since I am not using one and just using a cloudflare tunnel it appears to make it somewhat more difficult. |
Beta Was this translation helpful? Give feedback.
-
|
I have created #7826 to better add this as a feature rather than a discussion. |
Beta Was this translation helpful? Give feedback.
Perfect, thanks for pointing me to the correct place. I have looked at the helmet.js for Cross-Origin-Resource-Policy and it does seem to default to
same-originif not specified in helmet.I haven't taken a look at how the config is implemented, but it may be as simple as adding something like this to the
apps/server/src/app.tsand then the user can choose an option from the allowed ResourcePolicy options,
same-origin,same-site, orcross-origin