#What is the recommended way to debug api requests.
22 messages · Page 1 of 1 (latest)
Are there any errors in the backend console?
There are no errors in the backend console
Can you specify what are you actually doing. Which request, what endpoint and params? Some screenshots maybe also
Hmm looks good at first glance. Are you sure the database is seeded?
Are you using sqlite or postgres in medusa-config?
I was following the marketplace tutorial till the point where we added the user module to main.ts https://dev.to/medusajs/create-an-open-source-commerce-marketplace-part-1-3m5k
Im using postgres locally. I checked and saw the users have been created in the user table
🤔
Only thing that comes to mind is you have seeded postgres database, but maybe you're actually using sqlite in medusa-config which isn't seeded?
Does GET http://localhost:9000/store/products return something?
hmm. That also returns a 401. Now i'm wondering if i misconfigured something
@dull hound So everything stats returning 401 the moment I add the loggedinuser middleware to the my user module
@Middleware({ requireAuth: true, routes: [{ method: "all", path: '*' }] })
export class LoggedInUserMiddleware implements MedusaMiddleware {
public async consume(req: MedusaAuthenticatedRequest, res: Response, next: NextFunction): Promise<void> {
if (req.user && req.user.userId) {
console.log("wtf");
const userService = req.scope.resolve('userService') as UserService;
const loggedInUser = await userService.retrieve(req.user.userId, {
select: ['id', 'store_id'],
});
req.scope.register({
loggedInUser: {
resolve: () => loggedInUser,
},
});
}
next();
}
}
but the endpoints work when change requireAuth to true in the middleware. @broken trench Is this expected behavior?