fix
This commit is contained in:
@@ -15,6 +15,7 @@ const publicDir = path.join(__dirname, '..', 'public')
|
||||
assertServerConfig()
|
||||
|
||||
const app = express()
|
||||
app.set('trust proxy', 1)
|
||||
app.use(sessionMiddleware())
|
||||
app.use(express.json({ limit: '2mb' }))
|
||||
|
||||
@@ -48,7 +49,14 @@ app.get('/', (_req, res) => {
|
||||
res.redirect('/login.html')
|
||||
})
|
||||
|
||||
const server = app.listen(config.port, () => {
|
||||
app.use((err, _req, res, _next) => {
|
||||
console.error('[server] Unbehandelter Fehler:', err)
|
||||
if (!res.headersSent) {
|
||||
res.status(500).json({ error: err.message || 'Interner Serverfehler' })
|
||||
}
|
||||
})
|
||||
|
||||
const server = app.listen(config.port, '0.0.0.0', () => {
|
||||
console.log(`Webklar Kundenbereich läuft auf Port ${config.port}`)
|
||||
verifyDatabaseAccess().then((result) => {
|
||||
if (result.ok) return
|
||||
|
||||
@@ -60,22 +60,6 @@ async function adminFetch(path, { method = 'GET', body, queries = [] } = {}) {
|
||||
error.status = response.status >= 500 ? 500 : response.status
|
||||
error.code = data?.code
|
||||
error.type = data?.type
|
||||
if (response.status === 401 && data?.type === 'user_unauthorized') {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7281/ingest/30e8e71c-b377-4e72-84f9-593826c6d234', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-Debug-Session-Id': '80bbfc' },
|
||||
body: JSON.stringify({
|
||||
sessionId: '80bbfc',
|
||||
location: 'appwriteAdmin.js:adminFetch',
|
||||
message: 'API key unauthorized',
|
||||
data: { path, status: response.status, type: data?.type, code: data?.code },
|
||||
hypothesisId: 'H9',
|
||||
timestamp: Date.now(),
|
||||
}),
|
||||
}).catch(() => {})
|
||||
// #endregion
|
||||
}
|
||||
throw error
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user