Cors Error even after changing buildout file : Volto

I assume you want to mimic a deployment on your local machine.

What I do in my local dev batou environment to set up http://voltodeployment.example.com/ is this:

<VirtualHost *:80>
    ServerName voltodeployment.example.com
    ServerAdmin webmaster@foo.ch
    DocumentRoot "/Users/someone/Sites/"
    ErrorLog "/Users/someone/log/apache2/voltodeployment.example.com.error.log"
    CustomLog "/Users/someone/log/apache2/voltodeployment.example.com.access.log" common
    RewriteEngine On
    # API
    RewriteRule ^/api/(.*) \
    http://localhost:8080/VirtualHostBase/http/voltodeployment.example.com:80/Plone/VirtualHostRoot/_vh_api/$1 [L,P]
    # app
    RewriteRule ^(.*)      http://localhost:3000/$1 [L,P]
</VirtualHost>

In buildout.cfg:

[instance1]
recipe = plone.recipe.zope2instance
…
zcml-additional =
  <configure xmlns="http://namespaces.zope.org/zope"
             xmlns:plone="http://namespaces.plone.org/plone">
  <plone:CORSPolicy
    allow_origin="http://localhost:3000,http://127.0.0.1:3000,http://localhost:10001,*.example.com"
    allow_methods="DELETE,GET,OPTIONS,PATCH,POST,PUT"
    allow_credentials="true"
    expose_headers="Content-Length,X-My-Header"
    allow_headers="Accept,Authorization,Content-Type,X-Custom-Header,Origin"
    max_age="3600"
    />
  </configure>

Run a production build:

PORT=3000 RAZZLE_API_PATH=http://voltodeployment.example.com/api/ yarn build

Start Volto in production mode:

yarn start:prod
1 Like