my website at ewancroft.uk
1import adapter from '@sveltejs/adapter-vercel';
2import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
3
4/** @type {import('@sveltejs/kit').Config} */
5const config = {
6 preprocess: vitePreprocess(),
7
8 kit: {
9 adapter: adapter({
10 // Vercel adapter configuration
11 runtime: 'nodejs20.x',
12 regions: ['iad1'], // Default to US East (adjust based on your target audience)
13 split: false, // Set to true to deploy routes as individual functions
14
15 // Edge runtime configuration (uncomment to use Edge Functions)
16 // runtime: 'edge',
17 // regions: 'all', // Deploy to all edge regions
18
19 // Memory and execution limits
20 memory: 1024, // MB (256, 512, 1024, 3008)
21 maxDuration: 10 // seconds (max execution time)
22 }),
23
24 // Alias configuration for cleaner imports
25 alias: {
26 $components: 'src/lib/components',
27 $lib: 'src/lib',
28 $utils: 'src/lib/utils',
29 $services: 'src/lib/services',
30 $helper: 'src/lib/helper'
31 },
32
33 // Disable CSRF origin checking for the webhook route so Ko-fi's server-to-server
34 // POST requests (which have no matching Origin header) are not rejected.
35 csrf: {
36 trustedOrigins: ['*']
37 },
38
39 // Prerender configuration
40 prerender: {
41 handleHttpError: 'warn',
42 handleMissingId: 'warn',
43 entries: ['*'] // Prerender all discoverable pages
44 },
45
46 // CSP configuration for security
47 csp: {
48 mode: 'auto',
49 directives: {
50 'default-src': ['self'],
51 'script-src': ['self', 'unsafe-inline', 'https://analytics.ewancroft.uk'],
52 'style-src': ['self', 'unsafe-inline', 'https://fonts.googleapis.com'],
53 'style-src-elem': ['self', 'unsafe-inline', 'https://fonts.googleapis.com'],
54 'img-src': ['self', 'data:', 'https:'],
55 'font-src': ['self', 'data:', 'https://fonts.gstatic.com'],
56 'connect-src': ['self', 'https:'],
57 'media-src': ['self', 'https:']
58 }
59 }
60 }
61};
62
63export default config;