Skip to content

Commit

Permalink
fix middleware issue
Browse files Browse the repository at this point in the history
- middleware needs to be defined *before* route
  • Loading branch information
cgawron committed Mar 13, 2024
1 parent 09aa727 commit 6693181
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,10 @@ app.get('/dashboard', (req, res) => {
}
});

app.get('/user', (req, res) => {
console.log('req.user', req.user);
res.send(req.user);
});

/**
* Middleware to check if the user is authenticated
*/
app.use((req, res, next) => {

let token = req.cookies.token;
Expand Down Expand Up @@ -122,6 +121,10 @@ app.use((req, res, next) => {

});

app.get('/user', (req, res) => {
res.send(req.user);
});

app.use(`${PREFIX}*`, proxy(API_URL, {
https: true,
proxyReqPathResolver: function (req) {
Expand Down

0 comments on commit 6693181

Please sign in to comment.