Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Directus
  3. Access-Control-Allow-Origin

Access-Control-Allow-Origin

Scheduled Pinned Locked Moved Solved Directus
6 Posts 3 Posters 2.1k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      S Offline
      samsls
      wrote on last edited by
      #1

      Hello there,
      I 'm trying to configure Directus with AgencyOS : A new "template" to build client portal. It seems to be a great tool you can discover there :

      The installation process seems to be ok until when i'm trying to login thru the frontend : A vercel App.

      Error Message from the frontend :
      [POST] "https://directus-agencyos.tools.sl-system.io/auth/login": <no response> Failed to fetch

      Error message from the chrome console :
      Access to fetch at 'https://directus-agencyos.tools.sl-system.io/auth/login' from origin 'https://portail-one.vercel.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

      So my question :
      How can i configure the Access-Control-Allow-Origin policy in Directus especialy and on Cloudron generally?

      Thanks a lot for your help

      Regards,
      Sam

      girishG 1 Reply Last reply
      2
      • S samsls

        Hello there,
        I 'm trying to configure Directus with AgencyOS : A new "template" to build client portal. It seems to be a great tool you can discover there :

        The installation process seems to be ok until when i'm trying to login thru the frontend : A vercel App.

        Error Message from the frontend :
        [POST] "https://directus-agencyos.tools.sl-system.io/auth/login": <no response> Failed to fetch

        Error message from the chrome console :
        Access to fetch at 'https://directus-agencyos.tools.sl-system.io/auth/login' from origin 'https://portail-one.vercel.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.

        So my question :
        How can i configure the Access-Control-Allow-Origin policy in Directus especialy and on Cloudron generally?

        Thanks a lot for your help

        Regards,
        Sam

        girishG Offline
        girishG Offline
        girish
        Staff
        wrote on last edited by
        #2

        @samsls said in Access-Control-Allow-Origin:

        Access to fetch at 'https://directus-agencyos.tools.sl-system.io/auth/login' from origin 'https://portail-one.vercel.app'

        Per this error, you have a vercel app . The frontend on vercel is querying your directus. I assume directus on Cloudron . You have to set CORS headers following https://docs.directus.io/self-hosted/config-options.html#cors . On Cloudron, you can set env vars in /app/data/env.sh . See https://docs.cloudron.io/apps/directus/#environment-variables

        1 Reply Last reply
        1
        • S Offline
          S Offline
          samsls
          wrote on last edited by
          #3

          Thanks it works.

          J 1 Reply Last reply
          1
          • girishG girish marked this topic as a question on
          • girishG girish has marked this topic as solved on
          • S samsls

            Thanks it works.

            J Offline
            J Offline
            JLX89
            wrote on last edited by
            #4

            @samsls said in Access-Control-Allow-Origin:

            Thanks it works.

            @samsls Curious on what you did to get this working? I'm facing the same issue. The default "ashley@example.com" works, but any created accounts are failing. I have the CORS set in env.sh, but I might be missing something.

            Oops! Something went wrong.
            [POST] "https://directus.domain.com/auth/login": 401
            
            S 1 Reply Last reply
            1
            • J JLX89

              @samsls said in Access-Control-Allow-Origin:

              Thanks it works.

              @samsls Curious on what you did to get this working? I'm facing the same issue. The default "ashley@example.com" works, but any created accounts are failing. I have the CORS set in env.sh, but I might be missing something.

              Oops! Something went wrong.
              [POST] "https://directus.domain.com/auth/login": 401
              
              S Offline
              S Offline
              samsls
              wrote on last edited by
              #5

              @JLX89
              This is not not 'Access-Control-Allow-Origin'
              But i faced this error too.
              Do you try to use AgencyOS? or only Directus ?
              Because if you use AgencyOS script you import a lot of things automatically. SO i can't confirm at 100% what i did.

              In my case, this error (401) disapeared when i use default admin account to install AgencyOS. And then only, i have created a new admin user.
              And magically, i can connect with the new account.

              Not very technical but it works. Hope it helps.

              J 1 Reply Last reply
              1
              • S samsls

                @JLX89
                This is not not 'Access-Control-Allow-Origin'
                But i faced this error too.
                Do you try to use AgencyOS? or only Directus ?
                Because if you use AgencyOS script you import a lot of things automatically. SO i can't confirm at 100% what i did.

                In my case, this error (401) disapeared when i use default admin account to install AgencyOS. And then only, i have created a new admin user.
                And magically, i can connect with the new account.

                Not very technical but it works. Hope it helps.

                J Offline
                J Offline
                JLX89
                wrote on last edited by JLX89
                #6

                @samsls Thanks for following up with me on this!

                I used the Directus CLI with a Token for the admin account to import the data into a "default vanilla installation of Directus". Everything imported without any issues. Afterwards, I deployed the front end using Vercel from a private GitHub repo.

                Based on the reply from @girish, I put some additional configuration into the env.sh file and restarted Directus.

                export CORS_ENABLED="true"
                export CORS_ORIGIN="domain1.com,app-name.vercel.app"
                export CORS_METHODS="GET,POST,PATCH,DELETE,OPTIONS"
                export CORS_ALLOWED_HEADERS="Content-Type,Authorization"
                export CORS_EXPOSED_HEADERS="Content-Range"
                export CORS_CREDENTIALS="true"
                export CORS_MAX_AGE="18000"
                

                I've placed that into the env.sh as a wide-open test to at least see if I could get it working, but no luck.

                I know there are some other options, that you can force some of these settings into your Vercel deployment using the vercel.json file, but haven't gotten to that yet.

                There are some open issues that it seems they're looking into based on their GitHub.

                • CORS issues for client portal in "PROD" like deployment
                • Fetch the data from the server side instead of the client?
                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search