Fireabase, ReactJS, SASS, Google Sign-in

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.
Please log in to post a comment
Log in with GitHubCommunity feedback
- @seanred360
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 helpful - @seanred360
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 helpful - @seanred360
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 helpful
Join 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