This is a serverless CORS proxy for the Luma API that allows frontend applications to fetch event data without running into CORS issues.
This project has been migrated from Val Town to Railway for better deployment options. See the migration files:
deno-server.ts + railway.toml (recommended)node-server.js + package.jsonRAILWAY_MIGRATION.mddeploy-to-railway.mdThe proxy:
Access-Control-Allow-Origin: *)After Railway deployment, your proxy will be available at:
https://[your-app-name].up.railway.app
Replace your direct Luma API calls with calls to your proxy:
// Instead of this (which gets blocked by CORS):
// fetch('https://api.lu.ma/public/v1/calendar/list-events')
// Use this:
fetch('https://[your-app-name].up.railway.app')
.then(response => response.json())
.then(data => {
console.log('Luma events:', data);
// Use your event data here
})
.catch(error => {
console.error('Error fetching events:', error);
});
You can pass any query parameters that the Luma API supports:
// Example with query parameters
fetch('https://[your-app-name].up.railway.app?calendar_id=your-calendar-id&after=2024-01-01')
.then(response => response.json())
.then(data => console.log(data));
To get only the next 3 upcoming events, add next3=true to your query:
// Get only the next 3 upcoming events
fetch('https://[your-app-name].up.railway.app?next3=true')
.then(response => response.json())
.then(data => {
console.log('Next 3 events:', data.entries);
// Check if we're showing past events as fallback
if (data._fallback === 'recent_past_events') {
console.log('No upcoming events found, showing most recent past events');
}
// data.entries will contain max 3 events, sorted by date
// If upcoming events exist: sorted earliest first
// If no upcoming events: shows 3 most recent past events
});
Smart Fallback: If no upcoming events are found, the proxy automatically returns the 3 most recent past events and adds a _fallback: "recent_past_events" field to let you know.
Optimized API Calls: When using next3=true, the proxy requests up to 100 events from Luma (instead of the default ~50) to ensure it finds upcoming events if they exist.
You can combine this with other parameters:
// Get next 3 events for a specific calendar
fetch('https://[your-app-name].up.railway.app?calendar_id=your-calendar-id&next3=true')
.then(response => response.json())
.then(data => console.log(data));
*) - this is intentional for maximum compatibilityFor Railway deployment, you can set environment variables:
LUMA_API_KEY = secret-FMPoZlwNgVJ0qkCSn2EIHpTUAThe proxy includes error handling and will return appropriate HTTP status codes:
405 for non-GET requests500 for API errorsā Railway advantages over Val Town:
You can test the proxy directly in your browser by visiting the proxy URL. It should return JSON data from the Luma API.