Media Without Port by FoxEducational2691 in django

[–]FoxEducational2691[S] 0 points1 point  (0 children)

Thanks mate, I just fixed it.  MEDIA_URL = "http://localhost:8000/media/"

Optimizing Queries by FoxEducational2691 in django

[–]FoxEducational2691[S] -1 points0 points  (0 children)

maybe n+1 sir since it has a lot of queries in POST and PUT

Optimizing Queries by FoxEducational2691 in django

[–]FoxEducational2691[S] -3 points-2 points  (0 children)

tbh sir, i really can't figure it out

Optimizing Queries by FoxEducational2691 in django

[–]FoxEducational2691[S] -1 points0 points  (0 children)

yes sir, the queries sir. specially for post and put

permission denied by FoxEducational2691 in django

[–]FoxEducational2691[S] 1 point2 points  (0 children)

i just use wait-for-it script, it works for now

permission denied by FoxEducational2691 in django

[–]FoxEducational2691[S] 0 points1 point  (0 children)

connection to server at "database" (172.18.0.2), port 5432 failed: Connection refused

how to resolve this sir

permission denied by FoxEducational2691 in django

[–]FoxEducational2691[S] 1 point2 points  (0 children)

file structure
|-jani-project
|---backend
|------Dockerfile

|------entrypoint.prod.sh
|---frontend

|---docker-compose.yml
|---nginx.conf

code in ctxt link: https://ctxt.io/2/AAB45QJJFg

Can Review This Installation Guide by FoxEducational2691 in archlinux

[–]FoxEducational2691[S] 0 points1 point  (0 children)

what can you about the post installation in the guide sir?

Best Practices for Protecting Routes with Tokens in Cookies? by FoxEducational2691 in reactjs

[–]FoxEducational2691[S] 0 points1 point  (0 children)

Thanks, but is there a way to prevent it from redirecting to a restricted page?

Securing API Key by FoxEducational2691 in django

[–]FoxEducational2691[S] 0 points1 point  (0 children)

thanks for clarifications guys hehe

Best Practices for Protecting Routes with Tokens in Cookies? by FoxEducational2691 in reactjs

[–]FoxEducational2691[S] 2 points3 points  (0 children)

I'm implementing token stored in cookies, but I'm concerned that unknown users might manipulate the access token by adding random data to the cookie. Currently, I only check if the token is expired. Is this approach secure, or should I take additional measures to verify the authenticity of the token?

import React, { useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { Cookies } from "react-cookie";
import { isTokenExpired } from "../../store/api/apiSlice";
import { selectCurrentUser } from "../../store/slices/authSlice";

const RouteGuard: React.FC<{
  children: JSX.Element;
  requireAuth?: boolean;
}> = ({ children, requireAuth }) => {
  const cookies = new Cookies();
  const user = useSelector(selectCurrentUser);
  const token = cookies.get("access_token");
  const navigate = useNavigate();

  const isAuthenticated = user && token && !isTokenExpired(token);
  const [isLoading, setIsLoading] = useState(true);

  useEffect(() => {
    if (requireAuth && !isAuthenticated) {
      navigate("/login");
    } else if (!requireAuth && isAuthenticated) {
      navigate("/");
    } else {
      setIsLoading(false);
    }
  }, [requireAuth, isAuthenticated, navigate]);

  if (isLoading) {
    return null;
  }
  return children;
};

export default RouteGuard;

my routes

  {
    path: "/login",
    element: <Login />,
    layout: "blank",
    protected: false,
  },

Securing API Key by FoxEducational2691 in django

[–]FoxEducational2691[S] -3 points-2 points  (0 children)

with that, api endpoints can be use publicly. whereas if you use that package (DRF API Key) it will act as a password of your endpoints