-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCaddyfile
More file actions
executable file
·56 lines (46 loc) · 1.39 KB
/
Caddyfile
File metadata and controls
executable file
·56 lines (46 loc) · 1.39 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
{
frankenphp
order php_server before file_server
}
:80 {
root * /app/public
# Health check - minimal info for Docker/monitoring
respond /health `{"status":"healthy","service":"api","timestamp":"{time.now.unix}"}` 200
# API endpoints - rewrite /api/search to /api/search.php
# Only allow GET and OPTIONS methods (OPTIONS for CORS preflight)
handle /api/* {
@disallowed_methods {
not method GET OPTIONS
}
handle @disallowed_methods {
header Content-Type "application/json"
respond `{"error":"Method Not Allowed","message":"Only GET and OPTIONS methods are allowed for API endpoints","status":405}` 405
}
# Check if the PHP file exists before executing
@api_file_exists file {path}.php
handle @api_file_exists {
rewrite * {path}.php
php_server
}
# Return 404 for non-existent API endpoints
header Content-Type "application/json"
respond `{"success":false,"error":"Endpoint not found","status":404}` 404
}
# Static assets - serve directly
handle /fonts/* {
file_server
}
handle /*.css {
file_server
}
handle /*.js {
file_server
}
# Root - serve index.html
handle / {
try_files /index.html
file_server
}
# 404 for everything else
respond 404
}