Design comparison
Solution retrospective
Hello,
This is my first time using firebase to my project, because of that I struggled to write clean code. and some problem that I encountered that is difficult for me to fixed. like in this application when you already logged and refresh the page there a error page that I don't know how to fixed.
Community feedback
- @seanred360Posted over 2 years ago
I would also use a different design for your page routing. You should have a login page and a homepage only. You need to make a "protected route". Basically when the user tries to go to the homepage, the router checks if they are logged in, if not it will not allow them to go to the homepage. Instead it will redirect them to the login page every time they try to go to the homepage. You can see this behavior in my project here. https://www.frontendmentor.io/solutions/full-stack-mern-react-firebase-rest-api-mongodb-L08z7tmdo
This design structure also allows you to forbid a user from viewing an account page that they do not own or an edit page for a comment they do not own.
edit: I see you do have a protected route, I would make the hompage the default "/" and login page as "/login"
You should change your routes to something like this:
<Routes> <Route exact path="/" element={ <Protected> <HomePageNameHere /> </Protected> } /> <Route path="/signup" element={<Signup />} /> </Routes>and change Protected.jsx to
const Protected = ({ children }) => { const { user } = useAuth(); if (!user) { return <Navigate to="/signup" />; }
return children; };
Marked as helpful1@hatwell-jonelPosted over 2 years ago@seanred360 I want also to address my problem in vercel this is the link [ https://frontendmentor-todo-react.vercel.app/ ] I don't why it throws an error says "firebase invalid key" but I double check my keys it is totally fined.
btw, thank you so much sir for your time and effort. I am so happy that there are people like you to willing to teach/help aspiring developer like me.
0@seanred360Posted over 2 years ago@hatwell-jonel The vercel errors mean you did not set the environment variables within the vercel website. You must manually put these variables in the vercel website and set them to the real values from Firebase. Do not spell them wrong.
REACT_APP_FIREBASE_API_KEY, REACT_APP_FIREBASE_AUTH_DOMAIN, REACT_APP_FIREBASE_DATABASE_URL, REACT_APP_FIREBASE_PROJECT_ID, REACT_APP_FIREBASE_STORAGE_BUCKET, REACT_APP_FIREBASE_MESSAGING_SENDER_ID, REACT_APP_FIREBASE_APP_ID, REACT_APP_FIREBASE_MEASUREMENT_ID,
Marked as helpful1@hatwell-jonelPosted over 2 years agoHello @seanred360,
I saw your portfolio and i am really amazed how you developed it. now I am developing my own portfolio and I just want to ask how did you do the GIFs on your projects in My Works section of your portfolio?
Thank you.
0@seanred360Posted over 2 years ago@hatwell-jonel It is the React awesome slider. I do not use gif, I use MP4 because the file size for gifs is too large. You can record a mp4 of your site with the Google Chrome extension, Loom.
Marked as helpful1 - @seanred360Posted over 2 years ago
When you refresh the page, your app looks for a HTML file named account. There is no such file do you are getting a 404 error. You need to tell firebase to redirect the user to the homepage when they navigate to /account instead of trying to get a page that does not exist. Your firebase.json should look like this.
{ "hosting": { "public": "build", "ignore": ["firebase.json", "/.*", "/node_modules/"], "rewrites": [ { "source": "", "destination": "/index.html" } ] } }
Marked as helpful1 - @seanred360Posted over 2 years ago
I tried to download and run your code, but you have dependency errors in your package.json. The version of React you have does not work with react-beautiful-dnd. It looks to me like you ran a forced update with NPM which is not a good idea. I am not sure how you got this to deploy with this problem as the react build script cannot run like this.
Marked as helpful1@hatwell-jonelPosted over 2 years agohello @seanred360,
thank you for your time viewing my work. I deploy in two platform firebase hosting and vercel. but unfortunately it only works in firebase. I just watch a video from youtube how to use firebase hosting then it works. do you have any recommendations how can I do it correctly. because the time I tried to deploy this work I encountered a lot of errors.
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord