wuhp commited on
Commit
c5fa5ac
·
verified ·
1 Parent(s): 7ef8627

Update server.ts

Browse files
Files changed (1) hide show
  1. server.ts +10 -2
server.ts CHANGED
@@ -86,6 +86,16 @@ async function startServer() {
86
  // __dirname is the directory where server.js is located (which should be 'dist' thanks to esbuild)
87
  const distPath = __dirname;
88
  console.log('[SYSTEM] Static dist path:', distPath);
 
 
 
 
 
 
 
 
 
 
89
  app.use(express.static(distPath, {
90
  setHeaders: (res, filePath) => {
91
  res.setHeader('Access-Control-Allow-Origin', '*');
@@ -94,8 +104,6 @@ async function startServer() {
94
  res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
95
  res.setHeader('Pragma', 'no-cache');
96
  res.setHeader('Expires', '0');
97
- } else {
98
- res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
99
  }
100
  }
101
  }));
 
86
  // __dirname is the directory where server.js is located (which should be 'dist' thanks to esbuild)
87
  const distPath = __dirname;
88
  console.log('[SYSTEM] Static dist path:', distPath);
89
+ // explicitly serve assets directory
90
+ app.use('/assets', express.static(path.join(distPath, 'assets'), {
91
+ setHeaders: (res, filePath) => {
92
+ res.setHeader('Access-Control-Allow-Origin', '*');
93
+ res.setHeader('Cross-Origin-Resource-Policy', 'cross-origin');
94
+ res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
95
+ }
96
+ }));
97
+
98
+ // serve the rest of dist
99
  app.use(express.static(distPath, {
100
  setHeaders: (res, filePath) => {
101
  res.setHeader('Access-Control-Allow-Origin', '*');
 
104
  res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
105
  res.setHeader('Pragma', 'no-cache');
106
  res.setHeader('Expires', '0');
 
 
107
  }
108
  }
109
  }));