This commit is contained in:
@ -1,40 +1,48 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import type { APIRoute } from "astro";
|
||||
import {
|
||||
getSpotifyCredentials,
|
||||
isSpotifyConfigured,
|
||||
} from "../../../utils/spotify";
|
||||
|
||||
export const GET: APIRoute = async () => {
|
||||
try {
|
||||
// Only check environment variables at runtime, not build time
|
||||
const clientId = process.env.SPOTIFY_CLIENT_ID;
|
||||
const clientSecret = process.env.SPOTIFY_CLIENT_SECRET;
|
||||
const refreshToken = process.env.SPOTIFY_REFRESH_TOKEN;
|
||||
const isConfigured = isSpotifyConfigured();
|
||||
|
||||
const isConfigured = !!(clientId && clientSecret && refreshToken);
|
||||
|
||||
if (!isConfigured) {
|
||||
console.log('Spotify integration disabled - missing environment variables:', {
|
||||
hasClientId: !!clientId,
|
||||
hasClientSecret: !!clientSecret,
|
||||
hasRefreshToken: !!refreshToken
|
||||
});
|
||||
const credentials = getSpotifyCredentials();
|
||||
console.log(
|
||||
"Spotify integration disabled - missing environment variables:",
|
||||
{
|
||||
hasClientId: !!credentials?.clientId,
|
||||
hasClientSecret: !!credentials?.clientSecret,
|
||||
hasRefreshToken: !!credentials?.refreshToken,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({
|
||||
configured: isConfigured
|
||||
}), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
configured: isConfigured,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error checking Spotify configuration:', error);
|
||||
return new Response(JSON.stringify({
|
||||
configured: false
|
||||
}), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
console.error("Error checking Spotify configuration:", error);
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
configured: false,
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
});
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user