Unable to deploy project to remote
terumik opened this issue · 2 comments
Hi Brett,
I tried for a day, but the deployment still did not work for me.
If you could give me some advice when you have time, it would be very much appreciated.
The deployment itself seems to be working, but both the front-end and back-end content is not being served, and the default FirebaseHosting screen is displayed. Please see the attached images.
No errors are shown in the browser console for FrontEnd.
As for the Backend, the default screen shows "Error loading the Firebase SDK, check the console".
Here is what I did.
// Front end
- ran
SET NODE_ENV=production
(ref: https://stackoverflow.com/a/11928210/13868142) - ran
npm run build
- in firebase.json, change
"hosting": {"public" : @"public"}
to
"hosting": { "public" : "build"}
- ran
firebase deploy --only hosting
// Backend
- enabled permissions as stated below
https://cloud.google.com/build/docs/deploying-builds/deploy-cloud-run#before_you_begin - in package.json, deleted
"strapi-connector-firestore": "../... /"
and ranstrapi-connector-firestore
- in Dockerfile, commented out
User node
(I had to do this in order to avoid "Error: EACCES: permission denied, mkdir '/usr/src/app/node_modules'") - from the cloud run console, add environment variable ADMIN_JWT_SECRET=JWT_token
- ran
npm run deploy:backend
=> Successfully deployed but the browser shows "Error loading the Firebase SDK, check the console." - thought I need to install firebase sdk, so ran
npm install --save firebase
under the cloud-run-and-hosting folder - ran npm run deploy:backend again => still have the same error
Thank you in advance.
The issue has been solved by rewriting the hosting configs in firebase.json file that was overwritten when ran firebase init as in the example project.
"hosting": { "public": "build", "rewrites": [ { "source": "/api/**", "run": { "serviceId": "api-admin", "region": "us-central1" } }, { "source": "**", "destination": "/index.html" } ] },
Also I had to add NODE_ENV=production
to .env file.
@terumik ok, glad you could solve it. Thanks.