WaspW
Wasp17mo ago
devrim

Tutorial API implementation doesn't work for me.

my main.wasp is
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;
  };


code compiles with no problems, but localhost:3000/api endpoint returns 401 instead of the api response. any ideas?
Was this page helpful?