@@ -62,14 +62,11 @@ export function createServer(options = {}) {
6262 const subdomainsEnabled = options . subdomains ?? false ;
6363 const baseDomain = options . baseDomain || null ;
6464 // Mashlib data browser is OFF by default
65- // mashlibCdn: if true, load from CDN; if false, serve locally
66- // mashlibModule: URL to ES module entry point (alternative to classic mashlib)
65+ // mashlibCdn: load from CDN; mashlibModule: URL to ES module entry point
6766 const mashlibModule = options . mashlibModule ?? false ;
68- const mashlibEnabled = options . mashlib || ! ! mashlibModule ;
6967 const mashlibCdn = options . mashlibCdn ?? false ;
68+ const mashlibEnabled = mashlibCdn || ! ! mashlibModule ;
7069 const mashlibVersion = options . mashlibVersion ?? '2.0.0' ;
71- // SolidOS UI (modern Nextcloud-style interface) - requires mashlib
72- const solidosUiEnabled = options . solidosUi ?? false ;
7370 // Git HTTP backend is OFF by default - enables clone/push via git protocol
7471 const gitEnabled = options . git ?? false ;
7572 // Nostr relay is OFF by default
@@ -179,7 +176,6 @@ export function createServer(options = {}) {
179176 fastify . decorateRequest ( 'mashlibCdn' , null ) ;
180177 fastify . decorateRequest ( 'mashlibVersion' , null ) ;
181178 fastify . decorateRequest ( 'mashlibModule' , null ) ;
182- fastify . decorateRequest ( 'solidosUiEnabled' , null ) ;
183179 fastify . decorateRequest ( 'defaultQuota' , null ) ;
184180 fastify . decorateRequest ( 'config' , null ) ;
185181 fastify . decorateRequest ( 'liveReloadEnabled' , null ) ;
@@ -193,7 +189,6 @@ export function createServer(options = {}) {
193189 request . mashlibCdn = mashlibCdn ;
194190 request . mashlibVersion = mashlibVersion ;
195191 request . mashlibModule = mashlibModule ;
196- request . solidosUiEnabled = solidosUiEnabled ;
197192 request . defaultQuota = defaultQuota ;
198193 request . config = { public : options . public , readOnly : options . readOnly } ;
199194 request . liveReloadEnabled = liveReloadEnabled ;
@@ -410,7 +405,7 @@ export function createServer(options = {}) {
410405 // Authorization hook - check WAC permissions
411406 // Skip for pod creation endpoint (needs special handling)
412407 fastify . addHook ( 'preHandler' , async ( request , reply ) => {
413- // Skip auth for pod creation, OPTIONS, IdP routes, mashlib, solidos-ui, well-known, notifications, nostr, git, and AP
408+ // Skip auth for pod creation, OPTIONS, IdP routes, mashlib, well-known, notifications, nostr, git, and AP
414409 const mashlibPaths = [ '/mashlib.min.js' , '/mash.css' , '/841.mashlib.min.js' ] ;
415410 const apPaths = [ '/inbox' , '/profile/card/inbox' , '/profile/card/outbox' , '/profile/card/followers' , '/profile/card/following' ,
416411 '/api/v1/apps' , '/api/v1/instance' , '/api/v1/accounts/verify_credentials' ,
@@ -424,7 +419,6 @@ export function createServer(options = {}) {
424419 request . method === 'OPTIONS' ||
425420 request . url . startsWith ( '/idp/' ) ||
426421 request . url . startsWith ( '/.well-known/' ) ||
427- request . url . startsWith ( '/solidos-ui/' ) ||
428422 ( nostrEnabled && request . url . startsWith ( nostrPath ) ) ||
429423 ( gitEnabled && isGitRequest ( request . url ) ) ||
430424 ( activitypubEnabled && apPaths . some ( p => request . url === p || request . url . startsWith ( p + '?' ) ) ) ||
@@ -464,72 +458,15 @@ export function createServer(options = {}) {
464458 }
465459 } , handleCreatePod ) ;
466460
467- // Mashlib static files (served from root like NSS does)
468- if ( mashlibEnabled ) {
469- if ( mashlibCdn ) {
470- // CDN mode: redirect chunk requests to CDN
471- // Mashlib uses code splitting, so it loads chunks like 789.mashlib.min.js
472- const cdnBase = `https://unpkg.com/mashlib@${ mashlibVersion } /dist` ;
473- const chunkPattern = / ^ \/ \d + \. m a s h l i b \. m i n \. j s ( \. m a p ) ? $ / ;
474-
475- fastify . addHook ( 'onRequest' , async ( request , reply ) => {
476- if ( chunkPattern . test ( request . url ) ) {
477- const filename = request . url . split ( '/' ) . pop ( ) ;
478- return reply . redirect ( 302 , `${ cdnBase } /${ filename } ` ) ;
479- }
480- } ) ;
481- } else {
482- // Local mode: serve from local files
483- const mashlibDir = join ( __dirname , 'mashlib-local' , 'dist' ) ;
484- const mashlibFiles = {
485- '/mashlib.min.js' : { file : 'mashlib.min.js' , type : 'application/javascript' } ,
486- '/mashlib.min.js.map' : { file : 'mashlib.min.js.map' , type : 'application/json' } ,
487- '/mash.css' : { file : 'mash.css' , type : 'text/css' } ,
488- '/mash.css.map' : { file : 'mash.css.map' , type : 'application/json' } ,
489- '/841.mashlib.min.js' : { file : '841.mashlib.min.js' , type : 'application/javascript' } ,
490- '/841.mashlib.min.js.map' : { file : '841.mashlib.min.js.map' , type : 'application/json' }
491- } ;
492-
493- for ( const [ path , config ] of Object . entries ( mashlibFiles ) ) {
494- fastify . get ( path , async ( request , reply ) => {
495- try {
496- const content = await readFile ( join ( mashlibDir , config . file ) ) ;
497- return reply . type ( config . type ) . send ( content ) ;
498- } catch {
499- return reply . code ( 404 ) . send ( { error : 'Not Found' } ) ;
500- }
501- } ) ;
502- }
503- }
504- }
461+ // Mashlib CDN mode: redirect chunk requests to CDN
462+ if ( mashlibEnabled && mashlibCdn ) {
463+ const cdnBase = `https://unpkg.com/mashlib@${ mashlibVersion } /dist` ;
464+ const chunkPattern = / ^ \/ \d + \. m a s h l i b \. m i n \. j s ( \. m a p ) ? $ / ;
505465
506- // SolidOS UI static files (modern Nextcloud-style interface)
507- // Serves from /solidos-ui/* - requires mashlib to be enabled as well
508- if ( solidosUiEnabled && mashlibEnabled ) {
509- const solidosUiDir = join ( __dirname , 'mashlib-local' , 'dist' , 'solidos-ui' ) ;
510-
511- // Serve all files under /solidos-ui/* path
512- fastify . get ( '/solidos-ui/*' , async ( request , reply ) => {
513- try {
514- // Get the path after /solidos-ui/
515- const filePath = request . url . replace ( '/solidos-ui/' , '' ) . split ( '?' ) [ 0 ] ;
516- const fullPath = join ( solidosUiDir , filePath ) ;
517-
518- // Determine content type based on extension
519- const ext = filePath . split ( '.' ) . pop ( ) ?. toLowerCase ( ) ;
520- const contentTypes = {
521- 'js' : 'application/javascript' ,
522- 'css' : 'text/css' ,
523- 'map' : 'application/json' ,
524- 'html' : 'text/html'
525- } ;
526- const contentType = contentTypes [ ext ] || 'application/octet-stream' ;
527-
528- const content = await readFile ( fullPath ) ;
529- return reply . type ( contentType ) . send ( content ) ;
530- } catch ( err ) {
531- request . log . error ( err , 'Failed to serve solidos-ui file' ) ;
532- return reply . code ( 404 ) . send ( { error : 'Not Found' } ) ;
466+ fastify . addHook ( 'onRequest' , async ( request , reply ) => {
467+ if ( chunkPattern . test ( request . url ) ) {
468+ const filename = request . url . split ( '/' ) . pop ( ) ;
469+ return reply . redirect ( 302 , `${ cdnBase } /${ filename } ` ) ;
533470 }
534471 } ) ;
535472 }
0 commit comments