diff --git a/package.json b/package.json index 6a951ca..d56db4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "SparkHub", - "version": "1.0.0", + "version": "1.1.0", "scripts": { "test": "bun test", "dev": "bun run --watch src/index.ts", diff --git a/src/index.ts b/src/index.ts index e0eaf7e..ae2dbd5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,11 +15,6 @@ initializeSparkWallet().catch(error => { }); const app = new Elysia(serverConfig.elysia) - .onAfterHandle(({ set }) => { - set.headers['Access-Control-Allow-Origin'] = '*'; - set.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; - set.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization'; - }) .use( swagger({ documentation: { @@ -29,8 +24,15 @@ const app = new Elysia(serverConfig.elysia) description: 'SPA for self-custodial Lightning Address', }, }, + path: '/swagger', + excludeStaticFile: true, }) ) + .onAfterHandle(({ set }) => { + set.headers['Access-Control-Allow-Origin'] = '*'; + set.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'; + set.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization'; + }) .use( staticPlugin({ assets: 'dist', @@ -259,8 +261,10 @@ const app = new Elysia(serverConfig.elysia) } ) - // Lightning Address endpoint for direct username access - .get('/:username', () => Bun.file('public/index.html')) + // Catch-all for SPA - must be last + .get('/:username', () => { + return Bun.file('public/index.html'); + }) .listen(process.env.PORT ?? 3000);