Change environment variable handling
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID;
|
||||
import { env } from '$env/dynamic/public';
|
||||
|
||||
export const isGoogleApiReady = writable(false);
|
||||
export const isSignedIn = writable(false);
|
||||
@@ -45,8 +44,13 @@ export function initGoogleClient(callback: () => void) {
|
||||
const scriptGsi = document.createElement('script');
|
||||
scriptGsi.src = 'https://accounts.google.com/gsi/client';
|
||||
scriptGsi.onload = () => {
|
||||
const clientId = env.PUBLIC_GOOGLE_CLIENT_ID;
|
||||
if (!clientId) {
|
||||
console.error('PUBLIC_GOOGLE_CLIENT_ID is not set in the environment.');
|
||||
return;
|
||||
}
|
||||
tokenClient = google.accounts.oauth2.initTokenClient({
|
||||
client_id: GOOGLE_CLIENT_ID,
|
||||
client_id: clientId,
|
||||
scope: 'https://www.googleapis.com/auth/drive.readonly https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
callback: (tokenResponse) => {
|
||||
if (tokenResponse?.access_token) {
|
||||
@@ -140,7 +144,7 @@ export function extractDriveFileId(url: string): string | null {
|
||||
];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
const match = url.match(pattern);
|
||||
const match = pattern.exec(url);
|
||||
if (match) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user