The Problem
In my JavaScript Project I try to call a firebase function from a Client. My current problem is that wether I set a region or not while initializing functions the called URL (from firebase function) always starts with the same region.
My Code
functions.js (Firebase function - Server)
exports.recursiveDelete = functions.region('europe-west1')
.runWith({
timeoutSeconds: 540,
memory: '2GB'
})
.https.onCall(async (data, context) => {
// Doing smth.
});
delete.js (Client)
const app = firebase.app();
const functions_delete = app.functions("europe-west1");
function deleteArtWork(path, pid) {
var deleteFn = functions_delete.httpsCallable('recursiveDelete');
deleteFn({ path: path, pid: pid }).then(function(result) {
logMessage('Delete success: ' + JSON.stringify(result));
window.location.href = "../";
}).catch(function(err) {
logMessage('Delete failed, see console,');
console.warn(err);
});
}
Firebase itself is correctly initialized because Firestore and Auth are having no trouble.
The Output
[Error] Preflight response is not successful
[Error] Fetch API cannot load https://us-central1-projectart-jjl.cloudfunctions.net/recursiveDelete due to access control checks.
[Error] Failed to load resource: Preflight response is not successful (recursiveDelete, line 0)
[Error] Unhandled Promise Rejection: ReferenceError: Can't find variable: logMessage
Why is Firebase function always trying to call the us-central1 function?
Did I do something wrong?
Help is appreciated.