api upload_video { // APIs and their implementations don't need to (but can) have the same name. fn: import { fooBar } from "@src/api/api", httpRoute: (GET, "/api"), auth: false, middlewareConfigFn: import { apiMiddleware } from "@src/api/api"}
api upload_video { // APIs and their implementations don't need to (but can) have the same name. fn: import { fooBar } from "@src/api/api", httpRoute: (GET, "/api"), auth: false, middlewareConfigFn: import { apiMiddleware } from "@src/api/api"}
my src/api/api.jsx is
export const fooBar = (req, res, context) => { console.log("req"); res.set("Access-Control-Allow-Origin", "*"); // Example of modifying headers to override Wasp default CORS middleware. res.json({ msg: `Hello, ${context.user ? "registered user" : "stranger"}!` }); }; export const apiMiddleware = (config) => { return config; };
export const fooBar = (req, res, context) => { console.log("req"); res.set("Access-Control-Allow-Origin", "*"); // Example of modifying headers to override Wasp default CORS middleware. res.json({ msg: `Hello, ${context.user ? "registered user" : "stranger"}!` }); }; export const apiMiddleware = (config) => { return config; };
code compiles with no problems, but localhost:3000/api endpoint returns 401 instead of the api response. any ideas?
Recent Announcements
Continue the conversation
Join the Discord to ask follow-up questions and connect with the community
W
Wasp
Rails-like framework for React, Node.js and Prisma. Build your app in a day and deploy it with a single CLI command.