diff --git a/routes/create/controllers/h5pPreviewController.js b/routes/create/controllers/h5pPreviewController.js
index b412bc7..e9d1cac 100644
--- a/routes/create/controllers/h5pPreviewController.js
+++ b/routes/create/controllers/h5pPreviewController.js
@@ -85,6 +85,26 @@ router.get('/core/h5p-core.js', asyncHandler(async (req, res) => {
res.type('application/javascript').sendFile(corePath);
}));
+/**
+ * GET /libs/* — Serve H5P library files (JS, CSS, fonts, images).
+ * Uses the existing /api/create/h5p-preview/ route so no nginx config is needed.
+ */
+router.get('/libs/*', (req, res) => {
+ const requestedPath = req.params[0];
+
+ // Security: prevent directory traversal
+ if (requestedPath.includes('..')) {
+ return res.status(400).send('Invalid path');
+ }
+
+ const filePath = path.join(H5P_LIBS_DIR, requestedPath);
+ res.sendFile(filePath, (err) => {
+ if (err) {
+ res.status(404).send('Library file not found');
+ }
+ });
+});
+
/**
* GET /quiz/:quizId/render — Render quiz questions as real H5P content in-browser.
* Each question gets its own numbered header + H5P.newRunnable() instance.
@@ -169,7 +189,9 @@ body { margin:0; padding:40px; font-family:-apple-system,BlinkMacSystemFont,"Seg
// Read directly from h5p-libs (no temp dir or symlinks needed).
const { cssFiles, jsFiles } = await resolveLibraryDependencies(syntheticH5pJson);
- const libBasePath = '/h5p-libs';
+ // Serve library files through the existing /api route — works on all environments
+ // without needing extra nginx/proxy configuration.
+ const libBasePath = '/api/create/h5p-preview/libs';
const cssTags = cssFiles.map(f => ` `).join('\n');
const jsTags = jsFiles.map(f => ` `).join('\n');
diff --git a/server.js b/server.js
index f5276c4..5636fb7 100644
--- a/server.js
+++ b/server.js
@@ -167,9 +167,6 @@ app.post('/Shibboleth.sso/SAML2/POST', (req, res) => {
// Static serving for extracted H5P preview files (before API routes to avoid rate limiting)
app.use('/h5p-preview-files', express.static(path.join(__dirname, 'routes', 'create', 'uploads', 'h5p-preview')));
-// Static serving for H5P library files (used by quiz preview rendering)
-app.use('/h5p-libs', express.static(path.join(__dirname, 'routes', 'create', 'h5p-libs')));
-
// Mount the API router FIRST (before static files)
app.use('/api/create', createRoutes);
diff --git a/vite.config.mts b/vite.config.mts
index 7f9e0c9..9ca6c6b 100644
--- a/vite.config.mts
+++ b/vite.config.mts
@@ -18,11 +18,6 @@ export default defineConfig(({ mode }) => ({
target: 'http://localhost:8051',
changeOrigin: true,
secure: false,
- },
- '/h5p-libs': {
- target: 'http://localhost:8051',
- changeOrigin: true,
- secure: false,
}
}
},