Node.js runs successfully in Postman using passport-local but has issues in Vue.js frontend
<p>I am using passport-local for user authentication. When I try to get the logged in user it works fine in postman but it shows the error message I set "You need to be logged in first to get the data". My users can log in successfully from vue js but when I try to get the logged in user my error message is shown. </p>
<p>This is my route: </p>
<pre class="brush:php;toolbar:false;">router.get('/jobs', auth ,async(req, res) => {
const jobs = await Job.find({}).sort({
createdAt : -1
})
console.log(req.user)//This works in postman but gives an error in vue js
res.send(jobs)
})</pre>
<p>I am using cors and specify origin and set credentials to true. </p>
<p>This is my frontend request: </p>
<pre class="brush:php;toolbar:false;">try{
const res = await axios.get('http://localhost:3000/jobs', {
withCredentials : true
})
this.jobs = await res.data
console.log(this.jobs) // Even though I'm logged in, it displays my error message
}catch(error) {
if(error.response) {
this.message = error.response.data
}
}</pre></p>