mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 08:26:22 +02:00
add chat-widget to monorepo
This commit is contained in:
parent
2a16a8ce31
commit
0df92e80c6
35 changed files with 10804 additions and 25 deletions
35
apps/chat_widget/app/api/bootstrap.js/route.ts
Normal file
35
apps/chat_widget/app/api/bootstrap.js/route.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
// Read the file once when the module loads
|
||||
const jsFileContents = fs.readFile(
|
||||
path.join(__dirname, 'bootstrap.js'),
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Reuse the cached content
|
||||
const template = await jsFileContents;
|
||||
|
||||
// Replace placeholder values with actual URLs
|
||||
const contents = template
|
||||
.replace('__CHAT_WIDGET_HOST__', process.env.CHAT_WIDGET_HOST || '')
|
||||
.replace('__ROWBOAT_HOST__', process.env.ROWBOAT_HOST || '');
|
||||
|
||||
return new Response(contents, {
|
||||
headers: {
|
||||
'Content-Type': 'application/javascript',
|
||||
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error serving bootstrap.js:', error);
|
||||
return new Response('Error loading script', { status: 500 });
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue