Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
jwt - vscode - postgresql DB connection/login project

i did so many things to solve this problem, i didn't. so i am asking some questions related to some error

when i run code server and client side without no error. but the screen is blank and console display error : [App.js:24] POST http://localhost:5000/authentication/verify 401 (Unauthorized)

https://github.com/ousecTic/pern-jwt-tutorial << the link

anyway, i just type the code below, but it doens't work.

app.js (client side)

import React, { Fragment, useState, useEffect } from "react";

import "react-toastify/dist/ReactToastify.css";
import {
  BrowserRouter as Router,
  Route,
  Switch,
  Redirect
} from "react-router-dom";

import { toast } from "react-toastify";

//components

import Login from "./components/Login";
import Register from "./components/Register";
import Dashboard from "./components/Dashboard";

toast.configure();

function App() {
  const checkAuthenticated = async () => {
    try {
      const res = await fetch("http://localhost:5000/authentication/verify", {
        method: "POST",
        headers: { jwt_token: localStorage.token }
      });

      const parseRes = await res.json();

      parseRes === true ? setIsAuthenticated(true) : setIsAuthenticated(false);
    } catch (err) {
      console.error(err.message);
    }
  };

server.js (server side)

 const express = require("express");
    const app = express();
    const cors = require("cors");
    
    //middleware
    
    app.use(cors());
    app.use(express.json());
    
    //routes
    
    app.use("/authentication", require("./routes/jwtAuth"));
    
    app.use("/dashboard", require("./routes/dashboard"));
    
    app.listen(5000, () => {
      console.log(`Server is starting on port 5000`);
    });

jwtauth (server side)

router.post("/verify", authorize, (req, res) => {
  try {
    res.json(true);
  } catch (err) {
    console.error(err.message);
    res.status(500).send("Server error");
  }
});

module.exports = router;

and i checked already below some things.

  1. i just changed react/react-dorm and others package version in package.json in the server/client side. cause it has been changed a lot so many errors occured. so i make the package the same version.
  2. And i checked DB connection / but it seems to work.

and this is my entire code : https://github.com/Ryandongyou/jwt_project_dongyou thank you :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!