mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-26 08:56:22 +02:00
fix chat-widget bootstrap loading
This commit is contained in:
parent
87b5a644a5
commit
e8c2708c63
2 changed files with 4 additions and 12 deletions
|
|
@ -1,21 +1,13 @@
|
|||
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'
|
||||
);
|
||||
// Fetch template once when module loads
|
||||
const templatePromise = fetch(process.env.CHAT_WIDGET_HOST + '/bootstrap.template.js')
|
||||
.then(res => res.text());
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Reuse the cached content
|
||||
const template = await jsFileContents;
|
||||
const template = await templatePromise;
|
||||
|
||||
// Replace placeholder values with actual URLs
|
||||
const contents = template
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue