So currently, I am using feathers client auth and local strategy to authenticate my single-page app.
I've added different middleware routes and I want to check if user is authenticated and if not, redirect them to /
.
This is one of my routes:
inside /src/middleware/index.php
app.get('/some-route', (req, res) => {
res.render('some-view.ejs');
});
I've tried something like
const cookieParser = require('cookie-parser');
const auth = require('@feathersjs/authentication');
app.get('/some-route', cookieParser(), auth.express.authenticate('local'), (req, res) => {
res.render('some-view.ejs');
});
But I only get missing credentials error, though in client side I am logged in and I can see the token in localStorage.
Am I missing something here? Thank you.
I think you should try the following code instead...