I am trying to deploy the firebase app from here and I am following this tutorial. I would like to deploy my firebase app. However, when I enter
firebase deploy
I get an error. Here are my logs:
egaumbp:web gg$ firebase deploy
=== Deploying to 'friendlychat-6e4c3'...
i deploying database, storage, hosting
i storage: checking rules for compilation errors...
Error: Compilation error in storage.rules:
[E] 3:12 - Unexpected '<'.
egaumbp:web gg$
I am logged in, and I have version 3.0.0 of the firebase toolkit, and I am doing this from a MacBook Pro (Retina, 13-inch, Late 2012), on OSX EL Capitan Version 10.11.2.
Many of the examples in the getting started guide use a convention of <placeholder> where the developer needs to provide some additional information to make the example function. In the first example from Understanding Firebase Storage Security Rules, the following code snippet is presented with the placeholder <your-firebase-storage-bucket>.
service firebase.storage {
match /b/<your-firebase-storage-bucket>/o {
// ... more rules ...
}
}
To fix the Unexpected '<' error in this case, replace the placeholder with friendlychat-6e4c3.appspot.com like so:
service firebase.storage {
match /b/friendlychat-6e4c3.appspot.com/o {
// ... more rules ...
}
}
A detailed overview of the supported syntax and functions is available at Learn to Secure Files. It's a good reference if you encounter more compilation errors.
Related
I cannot get Firebase AppCheck to work in production mode on a Vue.js project with Firestore and Storage. But It works normally in development.
const appCheck: AppCheck = initializeAppCheck(firebaseApp, {
provider: new ReCaptchaV3Provider(reCaptchaSiteKey),
isTokenAutoRefreshEnabled: true,
});
getToken(appCheck)
.then((result: AppCheckTokenResult) => {
console.log(process.env.NODE_ENV);
console.log(result.token);
})
.catch((e: FirebaseError) => {
console.log(process.env.NODE_ENV);
console.log(e.code + ": " + e.message);
});
In Development mode, using vite, get the token back:
In Production mode, with firebase serve, get appCheck/fecth-status-error:
Firebaser here!
The error you are receiving is due to the App Check backend not being able to verify the underlying reCAPTCHA attestation.
Things to check for:
is reCAPTCHA providing a valid attestation and not somehow thinking your device is a bot?
does the site secret uploaded to App Check for this App match the client ID you are using in the App?
If you are using a Debug Token in your development build, that might explain why that one is succeeding.
I have a simple React frontend application that uses Firebase for Auth and Firestore (https://jlowen-netflix.netlify.app/ if additional context helpful). I provide Firebase as a Context to my top-level application, and listen for a change in Auth to redirect the user to logged in content.
I would like to test end-to-end user workflow from anonymous, to sign-up, to logged in. I have already installed the Firebase CLI as well as the Firebase emulators. I can verify the emulators run correctly by visiting the Emulator UI on localhost. I also can verify the application hooks in to the emulators when I start the dev server (npm start) for Create-React-App. I made a test user in the Emulator UI, and was able to log in as expected.
When I try to get this to render in Jest, my auth listener custom hook attempts to access the auth() method on the firebase context prior to firebase initialization.
TypeError: Cannot read property 'auth' of undefined
9 | // As recommended by Firebase - need to set up subscription
10 | useEffect(() => {
> 11 | const listener = firebase.auth().onAuthStateChanged((authUser) => {
| ^
12 | console.log(`Firebase detected auth change: ${authUser}`)
13 | if (authUser) {
14 | localStorage.setItem("authUser", JSON.stringify(authUser))
at src/hooks/use-auth-listener.js:11:31
I can't seem to resolve what seems to be some sort of async issue that I encounter in Jest, but does not occur in the deployed application.
I am pretty new in React and Jest, so if I can provide additional information, please let me know!
Unfortunately your error doesn't seem to be related to your main question. What the error you're showing says is that you forgot to import or require the firebase from somewhere. Read the firebase package docs and add something like this at the top of your file:
var firebase = require('firebase');
I would also be interested in connecting firebase app to local emulators, so will edit this answer if I figure something out. In the mean time.. sorry for the false hope.
We are using the firebase emulators to write integration tests. One of our functions modifies the claims on a user. As such, our test checks to see if the claim has been added. In our test, we call the following function:
admin.auth().getUser(user.userId)
Our intention is to then check the claims. Unfortunately, when this function is called, we get an error.
(node:96985) UnhandledPromiseRejectionWarning: Error: Credential
implementation provided to initializeApp() via the "credential"
property failed to fetch a valid Google OAuth2 access token with the
following error: "Error fetching access token: Error while making
request: getaddrinfo ENOTFOUND metadata.google.internal. Error code:
ENOTFOUND".
Keep in mind we are running against the local auth emulator, not a cloud service. We found an issue on github which seems to be related: https://github.com/firebase/firebase-tools/issues/1708
Unfortunately, the recommended course of action in that issue is to use an actual service account file from an actual cloud service. We do not check such files into our repos as this would be a security hazard. Does anyone know of a better way to deal with this situation?
In case it is relevant, we also get the following warning:
{"severity":"WARNING","message":"Warning, FIREBASE_CONFIG and
GCLOUD_PROJECT environment variables are missing. Initializing
firebase-admin will fail"}
While developing my app in Node.js, I decided to persist my data by using the Google Cloud Storage client libraries.
I came across the error mentioned in the title when uploading to storage:
Error: Could not load the default credentials
I did some digging, and figured out how to solve the issue:
Navigating to google cloud console credentials and creating a service account.
Setting the role for the service account to have full object permissions across my project and my buckets
Creating a key for the service account and downloading the associated .json file
Installing Cloud SDK and running the commands:
gcloud auth application-default login
gcloud config set project [MY_PROJECT_ID]
gcloud auth activate-service-account --key-file=C:/path/to/json/file
In my code passing in the .json credentials file into my new client instance:
const storage = new Storage({keyFileName: "auth.json"})
These steps described fixed the issue... in development. When I deployed my app to production the same error message comes back
I tried a few things to solve the issue. I assumed it was an issue with my web host: A2. After talking with their tech support they reassured me my file paths are correct inside their file structure, but they would not help me troubleshoot the credentials error otherwise.
So, why would my credentials be working just fine in development, but then suddenly stop working in production? Is it because I had the localhost as the callback URI instead of the domain name (or something)? Do I need to specify the domain somewhere in SDK or in the cloud console?
The error message points me to https://cloud.google.com/docs/authentication/getting-started, but I have read and reread the documentation many times, so if someone can point me to the specific place in the docs that says what I need to do that would be appreciated, but be aware that I have done my homework and I RTFM, but I am still unable to solve this issue.
I'm trying to get a hand with Netlify and AWS. I have downloaded a sample REST API preset from the official serverless site here.
The site worked locally after serverless deploy including the create route, used to add new todo elements into the db (API gateway on Amazon shows no issues)
I wanted to test how would it work on netlify, so I created a bitbucket repo from the file and uploaded it into the netlify servers.
From the start, there were minor issues. Such as an error claiming that TableName which in code is created from process.env.DYNAMODB_TABLE was not provided.
After replacing the value with the value of the field, I got an error saying that
{User: arxxxx:assumed-role/aws-lambda-execute/xxx is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-xxx-1:xxx:table/serverless-rest-api-with-dynamodb-dev","code":"AccessDeniedException","time":"xxx","requestId":"xxx","statusCode":400,"retryable":false,"retryDelay":30.76949318814495}
The issue suggests that my serverless parameters are wrong, however I do have the permissions set:
provider:
name: aws
runtime: nodejs6.10
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
And all seem to work fine when the data is local.
Has anyone ever had such issue?