Knowledge Base
CORS issue
If you have completed the above procedure but you can’t access the dApp because you get an error like this:

Then you need to configure your web server to accept request from application running in the browser context, not from servers. ObjectID is a distributed application so falls in the first case.
Normally web server do accept calls from the web app, but the Broweser check the response for a specif authorization from the server and if do not find it, then block the web app.
This process is managed by a protocol called CORS. Here you can find more information on CORS.
Here you can find some common case of web server configurations that solve the CORS issue.
Docker and Traefik
If your website is served by a Docker container and you use Traefik as a reverse proxy, you can resolve the CORS issue by adding a middleware configuration to your web server container in the docker-compose.yaml
file.
Add the bold section below and restart the container:
If your website is served by a Docker container and you use Traefik as a reverse proxy, you can resolve the CORS issue by adding a middleware configuration to your web server container in the docker-compose.yaml
file.
Add the bold section below and restart the container:
labels:
– “traefik.enable=true”
– “traefik.http.routers.vc.rule=Host(your.web.url)”
– “traefik.http.routers.vc.entrypoints=websecure”
– “traefik.http.routers.vc.tls.certresolver=myresolver”
– “traefik.http.services.vc.loadbalancer.server.port=81”
– “traefik.http.middlewares.cors.headers.accesscontrolallowmethods=GET,OPTIONS”,
– “traefik.http.middlewares.cors.headers.accesscontrolalloworiginlist=*”
– “traefik.http.middlewares.cors.headers.accesscontrolallowheaders=*”
– “traefik.http.middlewares.cors.headers.addvaryheader=true”
– “traefik.http.routers.vc.middlewares=cors”
Nginx
if you are using NGINX, then you need to add the middleware in the nginex.conf file in
/etc/nginx/sites-available/default
or
/etc/nginx/nginx.conf
inside the server or location block, add the following line and then restart nginx:
location = /.well-known/did-configuration.json {
add_header ‘Access-Control-Allow-Origin’ ‘https://dapp.objectid.io/’ always;
add_header ‘Access-Control-Allow-Methods’ ‘GET, OPTIONS’ always;
add_header ‘Access-Control-Allow-Headers’ ‘Origin, Content-Type, Accept’ always;
if ($request_method = OPTIONS ) {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
}
Need Help?
If you’re stuck or using a non-standard setup, feel free to reach out to our support.