Reputation: 957
Firebase hosting multiple sites with dynamic content. Below file i am using target based hosting to one of the site. But some how it is failing.
command to apply target to site
target:apply hosting target-name target-site
Command for deployment
firebase deploy --only hosting:target-name
firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"hosting": {
"public": "public",
"target": "target-name",
"rewrites": [
{
"source": "/**",
"function": "function"
}
]
}
}
ErrorLogs:
> [2019-08-02T08:02:33.699Z]
> ---------------------------------------------------------------------- [2019-08-02T08:02:33.703Z] Command:
> /home/johndoe/.nvm/v10.9.0/bin/node
> /home/johndoe/.nvm/v10.9.0/bin/firebase deploy --only
> hosting:target-name --debug [2019-08-02T08:02:33.703Z] CLI Version:
> 6.4.0 [2019-08-02T08:02:33.703Z] Platform: linux [2019-08-02T08:02:33.703Z] Node Version: v10.9.0
> [2019-08-02T08:02:33.704Z] Time: Fri Aug 02 2019 13:32:33
> GMT+0530 (India Standard Time) [2019-08-02T08:02:33.704Z]
> ----------------------------------------------------------------------
>
> [2019-08-02T08:02:33.712Z] > command requires scopes:
> ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
> [2019-08-02T08:02:33.713Z] > authorizing via signed-in user
> [2019-08-02T08:02:33.713Z] [iam] checking project first for
> permissions ["firebase.projects.get","firebasehosting.sites.update"]
> [2019-08-02T08:02:33.718Z] >>> HTTP REQUEST POST
> https://cloudresourcemanager.googleapis.com/v1/projects/first:testIamPermissions
> permissions=[firebase.projects.get, firebasehosting.sites.update]
> [2019-08-02T08:02:35.337Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:56 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> server-timing=gfet4t7; dur=1407, alt-svc=quic=":443"; ma=2592000;
> v="46,43,39", accept-ranges=none, transfer-encoding=chunked
> [2019-08-02T08:02:35.340Z] >>> HTTP REQUEST GET
> https://firebase.googleapis.com/v1beta1/projects/first
> [2019-08-02T08:02:35.816Z] <<< HTTP RESPONSE 200
> content-type=application/json; charset=UTF-8, vary=X-Origin, Referer,
> Origin,Accept-Encoding, date=Fri, 02 Aug 2019 08:05:57 GMT,
> server=ESF, cache-control=private, x-xss-protection=0,
> x-frame-options=SAMEORIGIN, x-content-type-options=nosniff,
> alt-svc=quic=":443"; ma=2592000; v="46,43,39", accept-ranges=none,
> transfer-encoding=chunked [2019-08-02T08:02:38.550Z] TypeError: Cannot
> read property 'deploys' of undefined
> at /home/prateekk/.nvm/v10.9.0/lib/node_modules/firebase-tools/lib/deploy/index.js:88:36
> at process._tickCallback (internal/process/next_tick.js:68:7)
Tutorails
Upvotes: 0
Views: 199
Reputation: 957
After lot of digging around. Finally it worked for me. Below is my firebase.json structure.
Used array structure for hosting and ran "firebase init hosting"- to reset firebase.json
firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "functions"
},
"hosting": [{
"public": "public",
"target": "target-name",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/**",
"function": "function"
}
]
}]
}
Upvotes: 0