Files
Map-Jurnal/scripts/set-cors2.mjs

33 lines
1017 B
JavaScript

import { readFileSync } from 'fs';
import { Storage } from '@google-cloud/storage';
const config = JSON.parse(readFileSync('C:/Users/tomas/.config/configstore/firebase-tools.json', 'utf-8'));
const storage = new Storage({
projectId: 'map-jurnal',
credentials: {
client_email: 'firebase-cli@map-jurnal.iam.gserviceaccount.com',
// We'll use token-based auth instead
},
});
// Try with direct token
const token = config.tokens.access_token;
// List all buckets to find the right name
const [buckets] = await storage.getBuckets({ project: 'map-jurnal' });
console.log('Buckets:', buckets.map(b => b.name));
if (buckets.length > 0) {
const bucket = buckets[0];
console.log('Configuring CORS for:', bucket.name);
await bucket.setCorsConfiguration([
{
origin: ['http://localhost:5173', 'https://map-jurnal.web.app', 'https://map-jurnal.firebaseapp.com'],
method: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE'],
maxAgeSeconds: 3600,
},
]);
console.log('CORS configured!');
}