-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathnetlify.toml
More file actions
500 lines (418 loc) · 13.7 KB
/
netlify.toml
File metadata and controls
500 lines (418 loc) · 13.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
[build]
publish = "dist"
command = "npm run build"
[build.environment]
NODE_VERSION = "20"
NPM_VERSION = "10"
NODE_OPTIONS = "--max-old-space-size=4096"
# Enable standard Netlify processing
[build.processing]
skip_processing = false
[build.processing.css]
bundle = true
minify = true
[build.processing.js]
bundle = false
minify = false
[build.processing.html]
pretty_urls = true
[build.processing.images]
compress = true
[dev]
command = "vite --port 5174"
framework = "#custom"
targetPort = 5174
publish = "dist"
autoLaunch = false
envFiles = [".env", ".env.local"]
# Deploy contexts
[context.production.environment]
# Production-specific env vars can go here
VITE_CONTEXT = "production"
NODE_OPTIONS = "--max-old-space-size=4096"
[context.deploy-preview.environment]
# Deploy preview specific env vars
CONTEXT = "deploy-preview"
VITE_CONTEXT = "deploy-preview"
# Pass Netlify deployment URLs to Vite
VITE_DEPLOY_PRIME_URL = "$DEPLOY_PRIME_URL"
VITE_DEPLOY_URL = "$DEPLOY_URL"
VITE_URL = "$URL"
NODE_OPTIONS = "--max-old-space-size=4096"
# NOTE: VITE_DUB_CO_KEY must be set in Netlify UI for oss.fyi link shortening
# Without it, share buttons will return original URLs instead of short links
[context.branch-deploy.environment]
# Branch deploy specific env vars
CONTEXT = "branch-deploy"
VITE_CONTEXT = "branch-deploy"
# Pass Netlify deployment URLs to Vite
VITE_DEPLOY_PRIME_URL = "$DEPLOY_PRIME_URL"
VITE_DEPLOY_URL = "$DEPLOY_URL"
VITE_URL = "$URL"
NODE_OPTIONS = "--max-old-space-size=4096"
[functions]
directory = "netlify/functions"
node_bundler = "esbuild"
# Edge Functions for SSR (Server-Side Rendering)
# These run BEFORE the SPA redirect and provide pre-rendered HTML for SEO/LCP
# Order matters: more specific paths are declared first
# SSR for home page - pre-rendered landing page for better LCP
[[edge_functions]]
function = "ssr-home"
path = "/"
# SSR for trending page - pre-rendered trending repos list
[[edge_functions]]
function = "ssr-trending"
path = "/trending"
# SSR for workspaces page - pre-rendered workspaces list (auth-aware)
[[edge_functions]]
function = "ssr-workspaces"
path = "/workspaces"
# SSR for workspace creation page
[[edge_functions]]
function = "ssr-workspace-new"
path = "/workspaces/new"
# SSR for individual workspace pages - pre-rendered for sharing/SEO
[[edge_functions]]
function = "ssr-workspace-detail"
path = "/i/*"
# SSR for repository pages - most important for SEO (frequently shared)
[[edge_functions]]
function = "ssr-repo"
path = "/:owner/:repo"
excludedPath = ["/api/*", "/assets/*", "/js/*", "/css/*", "/icons/*", "/login", "/settings", "/admin/*", "/dev/*", "/i/*", "/workspaces/*", "/trending", "/widgets", "/changelog", "/privacy", "/terms", "/billing", "/invitation/*", "/spam/*", "/*.js", "/*.css", "/*.json", "/*.png", "/*.svg", "/*.ico"]
# SSR for profile pages (user/org)
# Must come after ssr-repo to avoid intercepting repo routes (though pattern differs)
# Matches single segment paths (e.g. /bdougie)
[[edge_functions]]
function = "ssr-profile"
path = "/:username"
excludedPath = ["/api/*", "/assets/*", "/js/*", "/css/*", "/icons/*", "/login", "/signup", "/settings", "/admin/*", "/dev/*", "/i/*", "/workspaces/*", "/trending", "/widgets", "/changelog", "/privacy", "/terms", "/billing", "/invitation/*", "/spam", "/*.js", "/*.css", "/*.json", "/*.png", "/*.svg", "/*.ico", "/*.txt", "/*.xml"]
# Edge Functions for social media meta tags
# Detects crawler user-agents and injects dynamic og:image URLs
[[edge_functions]]
function = "social-meta"
path = "/*"
# Inngest functions need longer timeouts for processing
# Note: inngest-prod migrated to Supabase Edge Functions (see docs/infrastructure/inngest-supabase-migration.md)
[functions.inngest]
node_bundler = "esbuild"
[functions.inngest-local-full]
node_bundler = "esbuild"
# Embeddings function needs esbuild with longer timeout for ML model loading
[functions.inngest-embeddings]
node_bundler = "esbuild"
# Use ESM format to support import.meta in the codebase
[functions.inngest-embeddings.esbuild]
format = "esm"
# Manual backfill functions may take longer
# Chat function requires ESM format for V2 function detection
# Needs extended timeout for multi-step LLM tool calls
[functions.chat]
node_bundler = "esbuild"
timeout = 26
[functions.chat.esbuild]
format = "esm"
[functions.backfill-trigger]
node_bundler = "esbuild"
[functions.backfill-status]
node_bundler = "esbuild"
[functions.backfill-events]
node_bundler = "esbuild"
# Specific API routes (these must come first)
# GitHub webhook redirects to Fly.io service
# Migration context: Webhooks moved from Netlify Functions to dedicated Fly.io service
# to resolve ~9,310 404 errors caused by timeout and cold start issues.
# Status 307 preserves POST method and request body for webhook payloads.
# See docs/infrastructure/fly-webhook-migration.md for full details
[[redirects]]
from = "/api/github-webhook"
to = "https://contributor-info-webhooks.fly.dev/webhook"
status = 307
force = true
[[redirects]]
from = "/api/github/webhook"
to = "https://contributor-info-webhooks.fly.dev/webhook"
status = 307
force = true
[[redirects]]
from = "/api/health"
to = "/.netlify/functions/health-check"
status = 200
force = true
# Dub.co short URL creation (server-side to bypass CORS and secure API key)
[[redirects]]
from = "/api/create-short-url"
to = "/.netlify/functions/create-short-url"
status = 200
force = true
# Inngest endpoint - migrated to Supabase Edge Function (stub implementation)
# Full function migration to be completed in follow-up work
# NOTE: Netlify redirects don't support environment variables.
# To update the Supabase URL, replace "egcxzonpmmcirmgqdrla" with your project ID
[[redirects]]
from = "/api/inngest"
to = "https://egcxzonpmmcirmgqdrla.supabase.co/functions/v1/inngest-prod"
status = 200
force = true
headers = {X-Forwarded-Host = "contributor.info"}
[[redirects]]
from = "/api/inngest-sync"
to = "https://egcxzonpmmcirmgqdrla.supabase.co/functions/v1/inngest-prod"
status = 200
force = true
headers = {X-Forwarded-Host = "contributor.info"}
# Inngest embeddings endpoint - Netlify Function for Node.js dependencies
# Handles embeddings generation which requires @xenova/transformers
[[redirects]]
from = "/api/inngest-embeddings"
to = "/.netlify/functions/inngest-embeddings"
status = 200
force = true
[[redirects]]
from = "/api/chat"
to = "/.netlify/functions/chat"
status = 200
force = true
[[redirects]]
from = "/api/hello"
to = "/.netlify/functions/hello"
status = 200
force = true
[[redirects]]
from = "/api/github/callback"
to = "/.netlify/functions/github-callback"
status = 200
force = true
# Queue event endpoint - migrated to Supabase Edge Function for better timeout handling
# NOTE: Netlify redirects don't support environment variables.
# To update the Supabase URL, replace "egcxzonpmmcirmgqdrla" with your project ID
[[redirects]]
from = "/api/queue-event"
to = "https://egcxzonpmmcirmgqdrla.supabase.co/functions/v1/queue-event"
status = 200
force = true
headers = {X-Forwarded-Host = "contributor.info"}
[[redirects]]
from = "/api/discover-repository"
to = "/.netlify/functions/api-discover-repository"
status = 200
force = true
[[redirects]]
from = "/api/validate-repository"
to = "/.netlify/functions/validate-repository"
status = 200
force = true
[[redirects]]
from = "/api/track-repository"
to = "/.netlify/functions/api-track-repository"
status = 200
force = true
[[redirects]]
from = "/api/repository-status"
to = "/.netlify/functions/api-repository-status"
status = 200
force = true
# GitHub App installation status
[[redirects]]
from = "/api/github-app/installation-status"
to = "/.netlify/functions/github-app-installation-status"
status = 200
force = true
# Manual Backfill API endpoints
[[redirects]]
from = "/api/backfill/trigger"
to = "/.netlify/functions/backfill-trigger"
status = 200
force = true
[[redirects]]
from = "/api/backfill/status/*"
to = "/.netlify/functions/backfill-status"
status = 200
force = true
[[redirects]]
from = "/api/backfill/cancel/*"
to = "/.netlify/functions/backfill-cancel"
status = 200
force = true
[[redirects]]
from = "/api/backfill/events"
to = "/.netlify/functions/backfill-events"
status = 200
force = true
# CODEOWNERS API - migrated to Supabase Edge Function for better timeout handling
# NOTE: Netlify redirects don't support environment variables.
# To update the Supabase URL, replace "egcxzonpmmcirmgqdrla" with your project ID
[[redirects]]
from = "/api/repos/*/*/codeowners"
to = "https://egcxzonpmmcirmgqdrla.supabase.co/functions/v1/codeowners/repos/:splat/codeowners"
status = 200
force = true
headers = {X-Forwarded-Host = "contributor.info"}
[[redirects]]
from = "/api/repos/*/*/suggest-reviewers"
to = "/.netlify/functions/api-suggest-reviewers"
status = 200
force = true
[[redirects]]
from = "/api/repos/*/*/suggested-codeowners"
to = "/.netlify/functions/api-suggested-codeowners"
status = 200
force = true
[[redirects]]
from = "/api/repos/*/*/file-tree"
to = "/.netlify/functions/api-file-tree"
status = 200
force = true
[[redirects]]
from = "/api/webhook/backfill-complete"
to = "/.netlify/functions/webhook-backfill-complete"
status = 200
force = true
[[redirects]]
from = "/api/trigger-inngest-sync"
to = "/.netlify/functions/trigger-inngest-sync"
status = 200
force = true
# Workspace sync API - migrated to Supabase Edge Function for better timeout handling
# NOTE: Netlify redirects don't support environment variables.
# To update the Supabase URL, replace "egcxzonpmmcirmgqdrla" with your project ID
[[redirects]]
from = "/api/workspace-sync"
to = "https://egcxzonpmmcirmgqdrla.supabase.co/functions/v1/workspace-sync"
status = 200
force = true
headers = {X-Forwarded-Host = "contributor.info"}
# Headers for proper MIME types and caching
# Note: Some headers are also in public/_headers, but these are kept for compatibility
# JavaScript MIME types - CRITICAL for ES modules
[[headers]]
for = "/*.js"
[headers.values]
Content-Type = "text/javascript; charset=utf-8"
X-Content-Type-Options = "nosniff"
[[headers]]
for = "/*.mjs"
[headers.values]
Content-Type = "text/javascript; charset=utf-8"
X-Content-Type-Options = "nosniff"
[[headers]]
for = "/js/*"
[headers.values]
Content-Type = "text/javascript; charset=utf-8"
X-Content-Type-Options = "nosniff"
Cache-Control = "public, max-age=31536000, immutable"
# CSS MIME types
[[headers]]
for = "/*.css"
[headers.values]
Content-Type = "text/css; charset=utf-8"
X-Content-Type-Options = "nosniff"
[[headers]]
for = "/css/*"
[headers.values]
Content-Type = "text/css; charset=utf-8"
X-Content-Type-Options = "nosniff"
Cache-Control = "public, max-age=31536000, immutable"
# Legacy workspace invitation redirects
# Handle old invitation link format that may still be in circulation
[[redirects]]
from = "/workspace/invitation/accept"
to = "/invitation/:token"
status = 301
force = false
query = {token = ":token"}
[[redirects]]
from = "/workspaces/invitation/accept"
to = "/invitation/:token"
status = 301
force = false
query = {token = ":token"}
# Redirect docs to subdomain documentation (SEO-friendly)
[[redirects]]
from = "/docs"
to = "https://docs.contributor.info"
status = 301
force = true
[[redirects]]
from = "/docs/*"
to = "https://docs.contributor.info/:splat"
status = 301
force = true
# Redirect changelog to docs subdomain
[[redirects]]
from = "/changelog"
to = "https://docs.contributor.info/changelog"
status = 301
force = true
# Redirect local TUI documentation to subdomain
[[redirects]]
from = "/local"
to = "https://local.contributor.info"
status = 301
force = true
# Redirect rules for SPA behavior
# All API redirects above have force = true so they take precedence
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
# Font and image optimizations
[[headers]]
for = "/*.woff2"
[headers.values]
Content-Type = "font/woff2"
# Image caching and optimization headers
[[headers]]
for = "/*.webp"
[headers.values]
Content-Type = "image/webp"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.avif"
[headers.values]
Content-Type = "image/avif"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.jpg"
[headers.values]
Content-Type = "image/jpeg"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.jpeg"
[headers.values]
Content-Type = "image/jpeg"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.png"
[headers.values]
Content-Type = "image/png"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.gif"
[headers.values]
Content-Type = "image/gif"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/*.svg"
[headers.values]
Content-Type = "image/svg+xml"
Cache-Control = "public, max-age=31536000, immutable"
[[headers]]
for = "/assets/*"
[headers.values]
Cache-Control = "public, max-age=31536000, immutable"
# Resource hints are handled via index.html and build-time injection
# HTTP/2 Server Push removed due to wildcard limitations with hashed filenames
# JavaScript MIME type fix
[[headers]]
for = "/*.js"
[headers.values]
Content-Type = "text/javascript; charset=utf-8"
X-Content-Type-Options = "nosniff"
[[headers]]
for = "/assets/*.js"
[headers.values]
Content-Type = "text/javascript; charset=utf-8"
Cache-Control = "public, max-age=31536000, immutable"
X-Content-Type-Options = "nosniff"