to do: troubleshoot missing token in request headers

This commit is contained in:
Mikayla Dobson
2023-02-11 21:51:39 -06:00
parent 90a5bdf128
commit 1b73fa6b99
13 changed files with 109 additions and 114 deletions

View File

@@ -1,4 +1,4 @@
import { Express } from 'express';
import express, { Express } from 'express';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import morgan from 'morgan';
@@ -19,8 +19,8 @@ declare module 'express-session' {
export const expressLoader = async (app: Express) => {
app.use(cors({ origin: origin }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(morgan('tiny'));
app.use(requireSessionSecret);

View File

@@ -56,6 +56,8 @@ export const authRoute = (app: Express) => {
const safeUserData = {
id: user.id,
firstname: user.firstname,
lastname: user.lastname,
handle: user.handle,
email: user.email,
datecreated: user.datecreated,

View File

@@ -8,6 +8,12 @@ const router = Router();
export const collectionRoute = (app: Express) => {
app.use('/app/collection', router);
router.use((req, res, next) => {
console.log('what gives');
console.log(req.body);
next();
})
router.get('/:id', async (req, res, next) => {
const { id } = req.params;
try {
@@ -30,7 +36,7 @@ export const collectionRoute = (app: Express) => {
router.post('/', async (req, res, next) => {
const data = req.body;
console.log(data);
console.log(req.body ?? "sanity check");
try {
const result = await CollectionInstance.post(data);

View File

@@ -25,7 +25,7 @@ export const routes = async (app: Express) => {
console.log(token);
if (!token) {
res.status(403).send("Unauthorized");
res.status(403).send("Unauthorized, did not receive token");
} else {
jwt.verify(token, process.env.SESSIONSECRET as string, (err, data) => {
if (err) {