Like what we’re doing? Star us on GitHub!

CORS issues even when origins specified

2 weeks ago

Not sure what I'm doing wrong here

export default buildConfig({
  serverURL: "",
  admin: {
    user: Admins.slug,
  cors: ["http://localhost:4200", "", ""],
  csrf: ["http://localhost:4200", "", ""],
  collections: [Admins, Users, Pages, Media, Documents],
  typescript: {
    outputFile: path.resolve(__dirname, "payload-types.ts"),
  graphQL: {
    schemaOutputFile: path.resolve(__dirname, "generated-schema.graphql"),
  routes: {
    api: '/payload/api',
    admin: '/payload/admin',
    graphQL: '/payload/graphql',
    graphQLPlayground: '/payload/graphql-playground'

and in server

    origin: ["http://localhost:4200", "", ""],
    credentials: true,
  • MichaelBOOM
    last week

    You are getting the error on an https URL and only have http URLs listed. Maybe try changing your (what I assume is a production) URL to https? Also if the 2nd snippet is from the same server that payload uses, I didn't need to set any CORS settings manually on the express instance.

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More