Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

CORS issue

default discord avatar
harkiratsingh3743last year
10

I am getting this error when I am trying to hit api/users endpoint 403 error



[12:12:46] ERROR (payload): Forbidden: You are not allowed to perform this action.


at executeAccess (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\auth\executeAccess.js:9:23)


at process.processTicksAndRejections (node:internal/process/task_queues:95:5)


at async find (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\collections\operations\find.js:38:24)


at async findHandler (C:\Users\HARKIRAT\OneDrive\Desktop\test payload\node_modules\payload\dist\collections\requestHandlers\find.js:19:24)



This is the error I am getting

  • default discord avatar
    notchrlast year

    Good morning

    @1098978780116168714

    - on your users Collection, do you have access control set?



      access: {
        read: () => true,
        create: () => true,
        update: () => true
      },


    It looks something like this



    And typically is the reason for permission issues like the above error

  • default discord avatar
    harkiratsingh3743last year

    Hi

    @1049775120559898725

    , The access control is not set in any of my collection I will set that but I am unable to access Users collection in the buildConfig. The Users collection was prebuilt at the time I initialized the buildConfig the following way



    export default buildConfig({


    // By default, Payload will boot up normally


    // and you will be provided with a base

    User

    collection.


    // But, here is where you define how you'd like Payload to work!


    });



    Can you please confirm me how I can get the Users collection so that I can add access to it

  • default discord avatar
    notchrlast year

    The Users collection is in your collections folder



    Are you able to locate the Users file?

  • default discord avatar
    harkiratsingh3743last year

    I have installed payload in a existing express app and In my src/collections folder I do not have Users file. I also tried to find Users file in the require('payload/dist/collections') also but I was unable to find

  • default discord avatar
    notchrlast year

    What is in your collections folder?

  • default discord avatar
    harkiratsingh3743last year

    Got resolved Thanks

  • default discord avatar
    streamerdlast year

    this solved my problem

  • default discord avatar
    notchrlast year
    @767698114806546443

    Glad that worked! Remember, those are good values for testing, but be cautious of having access settings that are too lax!

  • default discord avatar
    streamerdlast year

    yep it's only read: () => true in my case 😉



    hello. I created a new collection type with just one field (media upload that refers to media collection) in a blank project. I was able to add once record. yet, in the next records I kept seeing an error:



    the following field is invalid: email

     const Testimonials: CollectionConfig = {
        slug: 'testimonials',
        fields: [
            { name: 'image', type: 'upload', relationTo: 'media', required: true }
        ],
        access: {
            read: () => true
          }
    };
    
    export default Testimonials;


    and this is my config:


    export default buildConfig({
      
      admin: {
        user: Users.slug,
      },
      collections: [
        Users,
        Treatments,
        Media,
        Testimonials
      ],
      typescript: {
        outputFile: path.resolve(__dirname, 'payload-types.ts'),
      },
      graphQL: {
        schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
      },
      plugins: [
        payloadCloud()
      ]
    });


    it is uploading the media but not saving the collection





    [13:16:45] ERROR (payload): ValidationError: The following field is invalid: email
        at create (/....../node_modules/payload/src/collections/operations/create.ts:213:11)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at createHandler (/..../node_modules/payload/src/collections/requestHandlers/create.ts:19:17)


    hey I understood the issue. it only works when auth: true in the CollectionConfig. but to be honest I don't like the fact that there is a need to fill email/password each time creating a new entry

  • default discord avatar
    fanki1995last year
    @767698114806546443


    I had the same issue, this fixed my problem:


    https://discord.com/channels/967097582721572934/1082933993009315920/1083230315109158933
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.