Cross-origin configuration

Updated at:

Cross-origin requests

image

If you use an HTTP-triggered cloud function on your website, your browser may display a cross-origin error. This occurs if you have not configured the required rules in the EMAS Serverless console. The error is similar to the one shown in the following figure:

This error occurs because your website requests a resource from the function's domain name, but the function's response does not include a Cross-Origin Resource Sharing (CORS) policy. To fix this issue, you can add the allowed origins to the Cross-origin configuration page in the EMAS Serverless console.

Add an allowed origin

Open the cloud function console. On the Cross-origin configuration page, click Add Domain Name in the upper-right corner.

The domain name rules are as follows:

1. You can specify a domain name, such as www.example.com.

2. A specific port number, such as www.example.com:8080

3. A wildcard prefix for the domain name, such as *.example.com

4. A wildcard for the port number, such as www.example.com:*

5. A wildcard for both the domain name prefix and the port, such as *.example.com:*

6. Support*

Note
  1. It takes about one minute for the configuration to take effect.

  2. You can add a maximum of 10 rules for each service space.

  3. Do not include the HTTP or HTTPS prefix in the domain name. The server-side supports both protocols by default.