Skip to content

feat(web): add content security policy (CSP)#25389

Closed
meesfrensel wants to merge 1 commit intomainfrom
feat/csp
Closed

feat(web): add content security policy (CSP)#25389
meesfrensel wants to merge 1 commit intomainfrom
feat/csp

Conversation

@meesfrensel
Copy link
Copy Markdown
Collaborator

@meesfrensel meesfrensel commented Jan 20, 2026

Description

Adds CSP config to svelte config which in turn generates and adds the Content-Security-Policy header.

Fixes #23261
Closes #24633

Related discussion on how to setup CSP and other security measures on the proxy side: #13043

(not sure what to do about the docker build failure)

How Has This Been Tested?

  • Navigate to all pages within Immich checking the console for CSP errors, including the map, hovering over all types of assets, opening the asset viewer for all types of assets (e.g. photo sphere viewer does some weird blob loading), etc.
  • Service worker loads
  • Justified layout wasm loads
  • Enable Google cast support which requires the gstatic.com domain
  • UNTESTED: custom map styles

Please describe to which degree, if any, an LLM was used in creating this pull request.

None

@github-actions
Copy link
Copy Markdown
Contributor

Deploying preview environment to https://pr-25389.preview.internal.immich.build/

Comment thread web/src/app.html
}
</style>
<script>
<script nonce="%sveltekit.nonce%">
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script might need to be externalized or hashed because the adapter-static prerenders the html.

@jrasm91
Copy link
Copy Markdown
Member

jrasm91 commented Jan 23, 2026

The svelte web server only responds to http requests in dev, not in production. In production the CSP headers need to be added by nodejs/nestjs/express. Did you test this with a production build or just the dev server?

@meesfrensel
Copy link
Copy Markdown
Collaborator Author

Ah, I didn't realize that. Will test/check/update and report back later!

@jrasm91
Copy link
Copy Markdown
Member

jrasm91 commented Feb 5, 2026

I'm like 99% sure this will require code changes on the nodejs side, so feel free to open a new PR if you get around to implementing that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsafe inline javascript SvelteKit and FOUC

2 participants