Fix admin API to serve admin.html on root route
- Updated server.js to serve admin.html on GET / - Fixed path to admin.html in Docker container - Admin panel now accessible at http://<ip>:3000
This commit is contained in:
@@ -2,11 +2,12 @@ FROM node:18-alpine
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY backend/package*.json ./
|
||||||
RUN npm install --production
|
RUN npm install --production
|
||||||
|
|
||||||
COPY server.js ./server.js
|
COPY backend/server.js ./server.js
|
||||||
COPY data/apps.json ./data/apps.json
|
COPY backend/data/apps.json ./data/apps.json
|
||||||
|
COPY frontend/admin.html ./admin.html
|
||||||
|
|
||||||
ENV PORT=3000
|
ENV PORT=3000
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ const PORT = process.env.PORT || 3000;
|
|||||||
const JWT_SECRET = process.env.JWT_SECRET || 'fallback-secret-key';
|
const JWT_SECRET = process.env.JWT_SECRET || 'fallback-secret-key';
|
||||||
const APPS_FILE = path.join(__dirname, 'data', 'apps.json');
|
const APPS_FILE = path.join(__dirname, 'data', 'apps.json');
|
||||||
|
|
||||||
|
// Serve admin frontend
|
||||||
|
const adminPath = path.join(__dirname, 'admin.html');
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
res.sendFile(adminPath);
|
||||||
|
});
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||||
|
|||||||
Reference in New Issue
Block a user