Change prod workflow and add automatic deployment
All checks were successful
Release Build / build-docker (push) Successful in 9s
Release Build / build-android-and-release (push) Successful in 2m18s

This commit is contained in:
Rene Kievits
2025-12-24 07:51:51 +01:00
parent c140bb8292
commit 8552b44ffd
14 changed files with 250 additions and 82 deletions

View File

@@ -11,29 +11,32 @@ const fastify = Fastify({ logger: true });
await connectDB();
const allowedOrigins = [
'http://192.168.0.26:5169',
'http://192.168.0.26:5173',
'http://localhost:5173',
'http://localhost',
process.env.SERVER_EXT_ACCESS,
process.env.SERVER_INT_ACCESS,
'https://localhost',
'capacitor://localhost',
'https://10.0.2.2:5173',
'https://zenkanji.crylia.de'
];
if (process.env.CORS_ORIGINS) {
const prodOrigins = process.env.CORS_ORIGINS.split(',');
allowedOrigins.push(...prodOrigins);
}
'http://localhost:5173'
].filter(Boolean).map(uri => uri.replace(/\/$/, ''));
await fastify.register(cors, {
origin: allowedOrigins,
methods: ['GET', 'POST', 'PUT', 'DELETE'],
origin: (origin, cb) => {
if (!origin) return cb(null, true);
if (allowedOrigins.includes(origin)) {
return cb(null, true);
}
console.log(`CORS BLOCKED: Browser sent "${origin}". Allowed list:`, allowedOrigins);
cb(new Error("Not allowed by CORS"));
},
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
credentials: true
});
await fastify.register(jwt, {
secret: JWT_SECRET
secret: process.env.JWT_SECRET
});
fastify.decorate('authenticate', async function (req, reply) {
@@ -67,7 +70,6 @@ await fastify.register(routes);
const start = async () => {
try {
await fastify.listen({ port: PORT, host: '0.0.0.0' });
console.log(`Server running at http://localhost:${PORT}`);
} catch (err) {
fastify.log.error(err);
process.exit(1);

View File

@@ -1,4 +1,3 @@
export const PORT = process.env.PORT || 3000;
export const MONGO_URI = process.env.MONGO_URI || 'mongodb://mongo:27017/zenkanji' || 'mongodb://192.168.0.26:27017/zenkanji';
export const SRS_TIMINGS_HOURS = [0, 2, 4, 8, 23, 47];
export const PORT = 3000;
export const MONGO_URI = process.env.MONGO_URI
export const JWT_SECRET = process.env.JWT_SECRET;