CORS für Hallenplaner-API auf halle.tkdduisburg.de erweitern
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
a518c6bbc4
commit
bd3593fb48
15
app.js
15
app.js
|
|
@ -93,6 +93,21 @@ const pool = new Pool({
|
||||||
connectionString: process.env.DATABASE_URL,
|
connectionString: process.env.DATABASE_URL,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// CORS für Hallenplaner-API
|
||||||
|
const ALLOWED_ORIGINS = ['https://halle.tkdduisburg.de'];
|
||||||
|
app.use('/api/layouts', (req, res, next) => {
|
||||||
|
const origin = req.headers.origin;
|
||||||
|
if (ALLOWED_ORIGINS.includes(origin)) {
|
||||||
|
res.setHeader('Access-Control-Allow-Origin', origin);
|
||||||
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
|
||||||
|
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
||||||
|
}
|
||||||
|
if (req.method === 'OPTIONS') {
|
||||||
|
return res.sendStatus(204);
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
// Api für Hallenplaner
|
// Api für Hallenplaner
|
||||||
app.get('/api/layouts', async (req, res) => {
|
app.get('/api/layouts', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue