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
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user