Spaces:
Runtime error
Runtime error
| export default function handler(req, res) { | |
| const { clientId, redirectUri } = req.body; | |
| if (!clientId) { | |
| return res.status(400).json({ error: 'Missing Client ID' }); | |
| } | |
| const scopes = [ | |
| 'user-read-private', | |
| 'user-read-email', | |
| 'user-top-read', | |
| 'user-library-read', | |
| 'playlist-read-private' | |
| ]; | |
| const params = new URLSearchParams({ | |
| client_id: clientId, | |
| response_type: 'code', | |
| redirect_uri: redirectUri, | |
| scope: scopes.join(' '), | |
| show_dialog: true | |
| }); | |
| const authUrl = `https://accounts.spotify.com/authorize?${params.toString()}`; | |
| res.status(200).json({ url: authUrl }); | |
| } |