#Van life project unexpected error
22 messages · Page 1 of 1 (latest)
@tribal vector
can you give more info, like what is your project about? it is using firestore?
yeah its van life project, but project is finished already but now im encountering that firebase issue https://scrimba.com/learn/reactrouter6
https://vanlifesai.netlify.app
this is the link which is hosted
Web site created using create-react-app
go to your firebase console then firestore database, you'll see a rules tab, check if you have sufficient permissions there,
So that date that is listed in the rules is created by firebase for testing purposes. It has long since expire so you need to update your rules. If you are using authentication and only want authenticated users to read or write data, then you would change “allow read, write: if request.time < time stamp….” To “allow read, write: if request.auth != null”. If you want everyone without being authenticated to read and write, you could do “allow read, write: if true” if I recall correctly. You can do a different rule for read and another one for write as well.
service cloud.firestore {
match /databases/{database}/documents {
// This rule allows anyone with your Firestore database reference to view, edit,
// and delete all data in your Firestore database. It is useful for getting
// started, but it is configured to expire after 30 days because it
// leaves your app open to attackers. At that time, all client
// requests to your Firestore database will be denied.
//
// Make sure to write security rules for your app before that time, or else
// all client requests to your Firestore database will be denied until you Update
// your rules
match /{document=**} {
allow read, write: if request.auth!= null;
}
}
}```
is this correct ?
but still im getting error
I think you need a space between “auth” and “!”. But also, if you are using firestore to show vans to people who are not logged in, then you will need to set the rule to “allow read: if true”. If you want people who are not logged in to be able to add vans (write to firestore database), then you need to make it “allow read, write: if true”.
You don’t want the user to have to be logged in to get the data from firestore if the intent of the site is to hold vans data for anyone to see on the site whether they are logged in or not. Does this make sense?
email and pass is manually stored in firebase and those who are logged in with same credentials only they have get access to vans and other details
i didnt mention this before sry for the confusion
So you are using firebase authentication, email and password method?
It’s been a while since I did the vans and I think they were using mirage.js to “host” the vans. Aren’t there vans for people to view who having signed up for an account yet? If that data is stored in a firestore collection, then the rule would have to be “allow read, write: if true”. If there are details for hosts or authenticated users in a different firestore collection, you can make that rule :if auth != null.
When someone first visits your site, and they aren’t authenticated yet, do you want to show vans or just a login/signup screen? If you want to show vans (but maybe not all the details that the host sees), Set the rule to “allow read, write: if true”. This should solve your immediate issue. If the only thing someone sees when they visit the site is a login/signup page and you don’t need that van data yet, then the rule you have should work. If you want to further refine your rules, I’d have to see your code. Does everyone who isn’t authenticated need write access (probably not) - I don’t know without seeing your code.
thanks this working allow read, write: if true