Giriş yapma halledildi.

This commit is contained in:
Batuhan 2025-02-16 02:39:51 +03:00
parent 2e5b507060
commit e3492635df
4 changed files with 30 additions and 13 deletions

View File

@ -9,13 +9,20 @@ const app = express();
// app.use(cookieParser()); // app.use(cookieParser());
app.use(bodyParser.urlencoded({extended: true})); app.use(bodyParser.urlencoded({extended: true}));
// app.use( app.use(
// cors({ cors({
// origin: ["http://192.168.1.15:3001"], origin: ["http://192.168.1.27:3001"],
// methods: ["GET", "POST"], methods: ["GET", "POST"],
// credentials: true credentials: true
// }) })
// ); );
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
app.use(express.urlencoded({extended: true})); app.use(express.urlencoded({extended: true}));
app.use(express.json()); app.use(express.json());
app.use(session({ app.use(session({

View File

@ -1,8 +1,3 @@
module.exports = (req, res, next) => { module.exports = (req, res, next) => {
const token = req.session; console.log(req.session);
if(req){
}else{
return res.json({Error: "You are not authenticated"});
};
}; };

6
modules/users/app.js Normal file
View File

@ -0,0 +1,6 @@
const express = require("express");
const app = express();
module.exports = app;

View File

@ -0,0 +1,9 @@
const express = require("express");
const auth = require("../../logins/middlewares/auth");
const router = express();
router.get("/profile", auth, (req, res) => {
res.json({name: "Batuhan", surname: "Coşkun"});
});
module.exports = router;