31 lines
969 B
JavaScript
31 lines
969 B
JavaScript
"use strict";
|
|
|
|
const express = require("express");
|
|
const router = express.Router();
|
|
|
|
/*
|
|
* Temporary debug endpoint to help trace requests reaching the Express
|
|
* application. This will return the raw URL, method, and headers as seen
|
|
* by the server. It is mounted under the application's basePath so you can
|
|
* hit: /<basePath>/__debug/request
|
|
*/
|
|
router.get('/__debug/request', (req, res) => {
|
|
try {
|
|
console.log('[debug] __debug/request hit:', req.method, req.originalUrl);
|
|
// Echo back a compact JSON summary so curl or browsers can inspect it.
|
|
res.json({
|
|
seenUrl: req.originalUrl,
|
|
url: req.url,
|
|
method: req.method,
|
|
headers: req.headers,
|
|
hostname: req.hostname,
|
|
basePath: req.app && req.app.get && req.app.get('basePath')
|
|
});
|
|
} catch (e) {
|
|
console.error('[debug] error in __debug/request', e && e.stack || e);
|
|
res.status(500).json({ error: 'debug endpoint error' });
|
|
}
|
|
});
|
|
|
|
module.exports = router;
|