Files
R3ap3r 3178b8f4f7 Aurora SpotiRip desktop and web app
- Spotify playlist, library, album and artist browsing with in-app playback
- Song, playlist and album downloads via spotdl with YouTube and Bandcamp fallbacks
- Electron desktop app (castLabs Widevine) with a permanent sidebar layout
- Linux and Windows packaging scripts
2026-09-25 23:20:57 -05:00

44 lines
1.3 KiB
TypeScript

import { makeCookie, SPOTIFY_REDIRECT_URI } from "../helpers/spotifyServer";
export async function handle() {
try {
const clientId = process.env.SPOTIFY_CLIENT_ID;
if (!clientId) {
return new Response("Spotify client ID is not configured.", { status: 500 });
}
const state = crypto.randomUUID().replace(/-/g, "");
const scopes = [
"playlist-read-private",
"playlist-read-collaborative",
"streaming",
"user-read-email",
"user-read-private",
"user-read-playback-state",
"user-modify-playback-state",
"user-library-read",
"user-follow-read",
].join(" ");
const params = new URLSearchParams({
client_id: clientId,
response_type: "code",
redirect_uri: SPOTIFY_REDIRECT_URI,
scope: scopes,
state,
show_dialog: "false",
});
const headers = new Headers({
Location: `https://accounts.spotify.com/authorize?${params.toString()}`,
"Cache-Control": "no-store",
});
headers.append("Set-Cookie", makeCookie("spotirip_oauth_state", state, { maxAge: 600 }));
return new Response("Redirecting to Spotify…", { status: 302, headers });
} catch (error) {
const message = error instanceof Error ? error.message : "Unable to start Spotify login.";
return new Response(message, { status: 500 });
}
}