<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Api on CSP Guide</title>
    <link>https://csp-guide.com/tags/api/</link>
    <description>Recent content in Api on CSP Guide</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Tue, 28 Jul 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://csp-guide.com/tags/api/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>CSP for API Routes in SvelteKit</title>
      <link>https://csp-guide.com/posts/csp-for-api-routes-in-sveltekit/</link>
      <pubDate>Tue, 28 Jul 2026 00:00:00 +0000</pubDate>
      
      <guid>https://csp-guide.com/posts/csp-for-api-routes-in-sveltekit/</guid>
      
      <description>&lt;p&gt;SvelteKit makes CSP pretty nice for pages, but API routes are where people get sloppy.&lt;/p&gt;
&lt;p&gt;I see this a lot: a team carefully sets &lt;code&gt;kit.csp&lt;/code&gt; for HTML pages, then their &lt;code&gt;/api/*&lt;/code&gt; endpoints return JSON with no security headers at all. That is usually fine for &lt;code&gt;script-src&lt;/code&gt; and friends — browsers don’t execute JSON as a document — but API routes still matter for CSP in a few real cases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;an endpoint returns HTML, SVG, PDF, or other renderable content&lt;/li&gt;
&lt;li&gt;an endpoint is used as a file download&lt;/li&gt;
&lt;li&gt;an endpoint serves inline bootstrapped JS or config&lt;/li&gt;
&lt;li&gt;you want a consistent policy surface across the app&lt;/li&gt;
&lt;li&gt;you need to control embedding with &lt;code&gt;frame-ancestors&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;you’re debugging weird browser behavior around MIME sniffing and resource loading&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the short version is this:&lt;/p&gt;</description>
      
    </item>
    
  </channel>
</rss>
