I have built a NUXT app, and I've added to it a serverMiddleware for handling some REST endpoints and connecting to my database.
serverMiddleware: [
{ path: "/api", handler: "~/api/index.js" },
],
So my question is: How to restrict accessing to /api endpoints from only few hosts ? (like having a list of ALLOWED_ORIGINS)
Setting
Access-Control-Allow-Originin the header solved the issue as explained more in-depth on this answer: https://stackoverflow.com/a/32481816/8816585Since at the end, this part of Nuxt is a regular Express app.