WaspW
Wasp11mo ago
mgp25

CORS issue - wasp 0.13

Basically we are getting a lot of CORS issues, such as:

Failed to load resource: the server responded with a status of 401 ()
Origin https://wislearn.io is not allowed by Access-Control-Allow-Origin. Status code: 504
XMLHttpRequest cannot load https://api.wislearn.io/operations/process-task due to access control checks.


The following is in main.wasp:

`
  wasp: {
    version: "^0.13.2"
  },
  server: {
    middlewareConfigFn: import { serverMiddlewareFn } from "@src/serverSetup"
  },


And serverSetup.ts content is:

`
import cors from 'cors'
import { config, type MiddlewareConfigFn } from 'wasp/server'

export const serverMiddlewareFn: MiddlewareConfigFn = (middlewareConfig) => {
  // Set up CORS with allowed origins
  middlewareConfig.set('cors', cors({ origin: [config.frontendUrl, 'https://api.wislearn.io', 'https://wislearn.io'] }));

  return middlewareConfig;
};


Pretty much as the guides and other examples shows. Any idea what could be happening?

Best regards
Was this page helpful?