-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreact-bundle.php
More file actions
33 lines (27 loc) · 1015 Bytes
/
react-bundle.php
File metadata and controls
33 lines (27 loc) · 1015 Bytes
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
<?php
/**
* Serve static React bundle with CORS headers
* This file serves ONLY the pre-built calendar-plus-react-bundle.js with CORS headers
*/
$request_method = $_SERVER['REQUEST_METHOD'] ?? 'UNKNOWN';
if (! in_array($request_method, ['GET', 'HEAD'], true)) {
http_response_code(405);
exit('Method not allowed');
}
// The static bundle file path
$bundle_path = __DIR__ . '/src/assets/calendar-plus-react-bundle.js';
// Verify file exists
if (! file_exists($bundle_path) || ! is_readable($bundle_path)) {
http_response_code(404);
exit('Bundle not found');
}
// Add CORS headers for external embedding
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: *');
header('Content-Type: application/javascript; charset=utf-8');
header('Cache-Control: public, max-age=31536000, immutable');
header('ETag: "' . md5_file($bundle_path) . '"');
header('Content-Length: ' . filesize($bundle_path));
readfile($bundle_path);
exit;