isoaxe / cors-server

A server to add CORS headers to a proxied request.
https://proxy-ibmasyzzya-uc.a.run.app
61 stars 130 forks source link

When trying to deploy using Firebase Functions, I keep getting an error #5

Closed restoredtemecula closed 1 year ago

restoredtemecula commented 1 year ago

Each time I attempt to deploy to Firebase Function I receive an error that says, "Error: An unexpected error has occurred." I have reached out to firebase support, but have not received a response as of yet. Curious, has anyone else seen this? I was able to find this in the logs in firebase.

Unable to retrieve the repository metadata for projects/restored-temecula-mobile-app/locations/us-central1/repositories/gcf-artifacts. Ensure that the Cloud Functions service account has 'artifactregistry.repositories.list' and 'artifactregistry.repositories.get' permissions. You can add the permissions by granting the role 'roles/artifactregistry.reader'.

isoaxe commented 1 year ago

Hi @restoredtemecula. Can you please provide the exact steps for reproduction of the error? Be as detailed as possible. Also provide some screenshots as they could be useful.

restoredtemecula commented 1 year ago

Sure thing. I followed all of your instructions outlined in your README for this repo. Each step listed below in sequence.

• First, I forked your repo and cloned it locally • Updated index.js (in the functions directory) with my whitelist requirements. • Ran npm install in functions directory • Then I attempted to install firebase-tool globally npm install -g firebase-tools (i already had firebase CLI, but did this to be certain I was on the latest. BUT ran into an error because my node.js version was not up to date enough for firebase-tools. So I updated node.js to version 18.12.1 • Then I installed firebase-tools • I already had an existing firebase project that did not use "Functions" and this proxy applies to the same project, so I filled in my project-id to the default value field { "projects": { "default": "restored-temecula-mobile-app" } } • Lastly, I double checked everything, than ran npm run deploy from the functions directory. And received an error in terminal after the attempted deploy.

image image

I also found the following in firebase-debug.log

[debug] [2022-11-13T23:47:46.069Z] TypeError: Cannot read properties of undefined (reading 'service') at /usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:198:113 at Array.map (<anonymous>) at loadExistingBackend (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:198:69) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.existingBackend (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/backend.js:174:9) at async prepare (/usr/local/lib/node_modules/firebase-tools/lib/deploy/functions/prepare.js:151:115) at async chain (/usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:35:9) at async deploy (/usr/local/lib/node_modules/firebase-tools/lib/deploy/index.js:79:5) [error] [error] Error: An unexpected error has occurred.

My copy your repo with the changes i made can be found here:

https://github.com/restoredtemecula/cors-server

Let me know if you need anything more in detail and I can provide. Appreciate your help!

restoredtemecula commented 1 year ago

I manually deleted the attempted deploy on Google Cloud Console, and reset Permissions and it all deployed fine. This issue can be closed. Now I have a separate issue however and I keep getting 503 errors every time I try to perform a POST through the CORS-anywhere firebase function I deployed.

Any idea why I'd be getting a 503 error when sending a simple POST request for the firebase function to handle?

isoaxe commented 1 year ago

I was just getting around to taking a look at the issue now, but good to see that you've resolved it. Thanks for providing such a detailed explanation of what you attempted.

If the other problem persists, feel free to open another issue on it providing similar detail. I'd like to keep the issues separate for future reference.