Files
service-master-data-revenue/src/routes/public.ts
2026-02-24 11:21:33 +07:00

53 lines
1.4 KiB
TypeScript

// import express from 'express';
// import { Language } from '../langs/lang';
// export class RoutePublic {
// static setup(app: express.Application) {
// app.use(Language.apply)
// }
// }
// import express from 'express';
// import { Language } from '../langs/lang';
// export class RoutePublic {
// static setup(app: express.Application) {
// app.use(Language.apply)
// }
// }
import express from 'express';
import path from 'path';
import fs from 'fs';
import { Language } from '../langs/lang';
export class RoutePublic {
static setup(app: express.Application) {
app.use(Language.apply);
// ⚠️ TAMBAHKAN INI - Serve static files untuk uploads
app.use('/uploads', express.static(path.join(__dirname, '../../uploads')));
// Atau dengan custom error handling (pilih salah satu):
/*
app.get('/uploads/*', (req, res) => {
const filePath = path.join(__dirname, '../../', req.path);
if (fs.existsSync(filePath)) {
res.set({
'Cache-Control': 'public, max-age=86400',
'Access-Control-Allow-Origin': '*'
});
res.sendFile(filePath);
} else {
res.status(404).json({
success: false,
message: 'File not found'
});
}
});
*/
}
}