A common issue is CORS errors when testing on a local environment on decoupled installations. This will guide you into fixing it.

In your sites/mysite/mysite.services.yml files, add the following and clear caches:

parameters:
    cors.config:
        enabled: true
        # Specify allowed headers, like 'x-allowed-header'.
        allowedHeaders: ['*']
        # Specify allowed request methods, specify ['*'] to allow all possible ones.
        allowedMethods: ['*']
        # Configure requests allowed from specific origins.
        allowedOrigins: ['http://localhost/','http://localhost:4000','http://localhost:3001','http://localhost:3002','*']
        # Sets the Access-Control-Expose-Headers header.
        exposedHeaders: false
        # Sets the Access-Control-Max-Age header.
        maxAge: false
        # Sets the Access-Control-Allow-Credentials header.
        supportsCredentials: true

 


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.