There appears to be an issue in FlutterFlow where changing the Cloud Function Regions under the cloud function panel and in advanced settings doesn't affect the deployment region well at least for me. All deployments seem to go to the default region even when europe-west6 (or another region) is selected in both places.
By looking at other posts I've found a workaround on how to set the region and other configurations, (also I'm using Cloud Functions 2nd gen instead which I was told isn't supported but still works for me):
const { onCall, HttpsError } = require("firebase-functions/v2/https");
const { logger } = require("firebase-functions");
const admin = require('firebase-admin');
// Note: Do not call admin.initializeApp()
exports.yourFunctionName = onCall(
{
region: 'europe-west6', // Change this to your desired region
memory: '128MiB' // Adjust memory as needed
},
async (request) => {
logger.info("Function started", {structuredData: true});
try {
// Your function logic here
// Example:
// if (!request.auth) {
// throw new HttpsError('unauthenticated', 'User must be logged in.');
// }
// const result = await someAsyncOperation();
// return { success: true, data: result };
} catch (error) {
logger.error('Error in function:', {
error: error.toString(),
stack: error.stack
});
throw new HttpsError('internal', 'An unexpected error occurred', error.message);
} finally {
logger.info("Function completed", {structuredData: true});
}
}
);