@lovelybunch/api 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,15 +104,26 @@ for (const possiblePath of possibleStaticPaths) {
104
104
  }
105
105
  }
106
106
  if (staticPath) {
107
- // Serve static files for all non-API routes
108
- app.use('/*', serveStatic({
109
- root: staticPath,
110
- // Serve index.html for all non-file routes (SPA routing)
111
- onNotFound: (_p, c) => {
107
+ // Serve static assets
108
+ app.use('/assets/*', serveStatic({ root: staticPath }));
109
+ // Serve specific static files
110
+ app.use('/vite.svg', serveStatic({ root: staticPath }));
111
+ app.use('/favicon.ico', serveStatic({ root: staticPath }));
112
+ // Serve index.html for all non-API, non-WebSocket routes (SPA routing)
113
+ app.get('*', async (c) => {
114
+ const requestPath = c.req.path;
115
+ // Don't serve index.html for API or WebSocket routes
116
+ if (requestPath.startsWith('/api/') || requestPath.startsWith('/ws/')) {
117
+ return c.text('Not Found', 404);
118
+ }
119
+ try {
112
120
  const html = fs.readFileSync(path.join(staticPath, 'index.html'), 'utf-8');
113
- c.html(html);
121
+ return c.html(html);
122
+ }
123
+ catch (error) {
124
+ return c.text('Not Found', 404);
114
125
  }
115
- }));
126
+ });
116
127
  }
117
128
  // Export function to start the server
118
129
  export async function startServer(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelybunch/api",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "main": "dist/server-with-static.js",
6
6
  "exports": {