Skip to content

Bitcoin: CORS error in Blockstream Esplora docker container even with `CORS_ALLOW=*`

Understand the Cors error in the splendid docker container

As a blockchain developer, it is likely to be familiar with the importance of the exchange of cross -source resources (CORS) when building applications that interact with external services. However, when working on projects such as Bitcoin, it is easy to ignore this characteristic of critical security.

In this article, we will deepen the Cors error in the context of spleen and its Docker container, specifically focusing on splendid blockstream.

What is Cors?

CORS is a security feature implemented in web browsers to prevent malicious scripts from making unauthorized requests on the username. It allows websites to communicate with their backend services without the need for a direct application.

In other words, when a browser makes an application to an application on the server side, you must authenticate the application and make sure that only authorized scripts can access confidential data.

Cors in the splendid docker container

As the splendid blockstream container running using Docker Run, you are likely to configure Cors to allow web applications such as your bitcoin node connect to the splendid server. However, if everything works as expected, the error may not be apparent immediately.

THE PROBLEM: CORS ERROR IN THE BLOCKSTREAM SPLORA DOCKER CONTAINER

When executing a docker container with cors_allow =*, it is possible that the browser or splendid server has configured an exception for the current IP address. This can cause a CORS error when trying to establish connections between the client and the server.

In his case, he is running the following command:

`Bash

DOCKER RUN --Name Spleer -Container -P 50001: 50001 -P 8094: 80 -VOLUM $ PWD/DATA_BITCOIN_REGTEST:/DATA -E CORS_ALLOW =* - -RM -I -T BLOCKSTREAM/SPLORA BASH -C & ...

The problem arises when it tries to establish a connection with the splendid server usingcurlor other web application:

Bash

Curl http: // localhost: 50001

You are likely to receive a CORS error response, which could see something like this:

JSON

{

"Message": "Warning of cross -source resources (Cors)",

"State": 0,

"URL": "/

}

What is behind Cors's error?

Thecors allowis established in*, which means that all web applications can make requests to the splendid server. However, this can lead to unexpected problems of behavior and security.

When a web application makes an application to the splendid server without adequate authentication or authorization, you can activate CORS restrictions, even if it has explicitly allowed cross -source access with cors_allow =*.

In your case, there are several possible reasons for which this problem could be experiencing:

  • Incorrect CORS configuration : Verify that you have not configured any incorrect Cors configuration on the splendid server or in its web application.

  • Exception of the IP address : The navigator or splendid server can have an IP address exception configuration, which can cause cors errors when trying to establish connections between the client and the server.

  • Docker container configuration : Verify that your Docker container is correctly configured, including the necessary variables or settings.

Solutions

To solve the Cors error in its splendid blockstream container:

  • Verify the cors policy of the browser

    Bitcoin: CORS error in Blockstream Esplora docker container even with `CORS_ALLOW=*`

    : Make sure you are allowing requests of cross origin of the web application made by the application to the splendid server.

  • Verify the exception of the IP address : Make sure there are no IP address exceptions configured in the client or the splendid server.

  • Update Docker configuration : Check the configuration of your Docker container and make sure you are correctly configured for Cors Access.

ETHEREUM BITCOIN BACKUP