Я пытаюсь проверить новые функции локально.
Структура файла проекта:
App/
typescript_functions/
flutter_web_app/
.firebaserc
firebase.json
firestore.indexes.json
firestore.rules
Запуск: firebase serve --only functions
из приложения / или из функций /
возвращает: Error: HTTP Error: 400, Request contains an invalid argument.
Это какая-то ошибка аутентификации?
Я понижен с node@12
до node@8
node -v
v8.16.2
npm -v
6.4.1
firebase --version
7.6.1
Я убедился, что мои .bash_profile
и .zshrc
пути к node
и npm
верны. Я могу опубликовать эти файлы, если это поможет.
Я запустил firebase logout
, а затем firebase login
без проблем. Я могу без проблем получить доступ к https://console.firebase.google.com
.
Я вышел из терминала и снова открыл его после понижения версии узла.
Я выключил и перезагрузил компьютер.
Структура файла проекта:
App/
typescript_functions/
flutter_web_app/
.firebaserc
firebase.json
firestore.indexes.json
firestore.rules
В приложении / firebase.json:
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
]
}
}
В функциях / package.json:
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase serve --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"main": "lib/index.js",
"dependencies": {
"@types/puppeteer": "^1.20.2",
"algoliasearch": "^3.35.0",
"axios": "^0.19.0",
"dotenv": "^8.2.0",
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",
"puppeteer": "^1.20.0"
},
"devDependencies": {
"@types/algoliasearch": "^3.34.3",
"@types/dotenv": "^6.1.1",
"jest-puppeteer": "^4.3.0",
"tslint": "^5.12.0",
"typescript": "^3.2.2"
},
"private": true
}
Запуск firebase serve --only functions --debug
Возвращает:
[2019-10-23T02:06:29.461Z] ----------------------------------------------------------------------
[2019-10-23T02:06:29.464Z] Command: /usr/local/Cellar/node@8/8.16.2/bin/node /usr/local/bin/firebase serve --only functions --debug
[2019-10-23T02:06:29.465Z] CLI Version: 7.6.1
[2019-10-23T02:06:29.465Z] Platform: darwin
[2019-10-23T02:06:29.465Z] Node Version: v8.16.2
[2019-10-23T02:06:29.465Z] Time: Tue Oct 22 2019 19:06:29 GMT-0700 (PDT)
[2019-10-23T02:06:29.465Z] ----------------------------------------------------------------------
[2019-10-23T02:06:29.466Z]
[2019-10-23T02:06:29.473Z] > 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-10-23T02:06:29.474Z] > authorizing via signed-in user
[2019-10-23T02:06:29.474Z] [iam] checking project [PROJECT] for permissions ["firebase.projects.get"]
[2019-10-23T02:06:29.476Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/[PROJECT]:testIamPermissions
permissions=[firebase.projects.get]
[2019-10-23T02:06:29.609Z] <<< HTTP RESPONSE 400 vary=X-Origin, Referer, Origin,Accept-Encoding, content-type=application/json; charset=UTF-8, date=Wed, 23 Oct 2019 02:06:29 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=59, alt-svc=quic=":443"; ma=2592000; v="46,43",h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000, accept-ranges=none, transfer-encoding=chunked
[2019-10-23T02:06:29.610Z] <<< HTTP RESPONSE BODY code=400, message=Request contains an invalid argument., status=INVALID_ARGUMENT
Error: HTTP Error: 400, Request contains an invalid argument.
[2019-10-23T02:06:29.673Z] Error Context: {
"body": {
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
},
"response": {
"statusCode": 400,
"body": {
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
},
"headers": {
"vary": "X-Origin, Referer, Origin,Accept-Encoding",
"content-type": "application/json; charset=UTF-8",
"date": "Wed, 23 Oct 2019 02:06:29 GMT",
"server": "ESF",
"cache-control": "private",
"x-xss-protection": "0",
"x-frame-options": "SAMEORIGIN",
"x-content-type-options": "nosniff",
"server-timing": "gfet4t7; dur=59",
"alt-svc": "quic=\":443\"; ma=2592000; v=\"46,43\",h3-Q048=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000",
"accept-ranges": "none",
"transfer-encoding": "chunked"
},
"request": {
"uri": {
"protocol": "https:",
"slashes": true,
"auth": null,
"host": "cloudresourcemanager.googleapis.com",
"port": 443,
"hostname": "cloudresourcemanager.googleapis.com",
"hash": null,
"search": null,
"query": null,
"pathname": "/v1/projects/[PROJECT]:testIamPermissions",
"path": "/v1/projects/[PROJECT]:testIamPermissions",
"href": "https://cloudresourcemanager.googleapis.com/v1/projects/[PROJECT]:testIamPermissions"
},
"method": "POST"
}
}
}
Я ожидаю, что смогу вызывать функции локально с http на localhost: 5000. Например:
curl "http://localhost:5000/project-name/us-central1/runMyFunction?someDocumentId=some-someDocumentId-hash&anotherDocumentId=some-anotherDocumentId-hash"
Вместо этого я получаю Error: HTTP Error: 400, Request contains an invalid argument.
Может кто-нибудь увидеть, где я иду не так?