Reference documentation and code samples for the Compute V1 Client class CorsPolicy.
The specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard.
Generated from protobuf messagegoogle.cloud.compute.v1.CorsPolicy
Namespace
Google \ Cloud \ Compute \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ allow_credentials
bool
In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
↳ allow_headers
array
Specifies the content for the Access-Control-Allow-Headers header.
↳ allow_methods
array
Specifies the content for the Access-Control-Allow-Methods header.
↳ allow_origin_regexes
array
Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
↳ allow_origins
array
Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
↳ disabled
bool
If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.
↳ expose_headers
array
Specifies the content for the Access-Control-Expose-Headers header.
↳ max_age
int
Specifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.
getAllowCredentials
In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
Returns
Type
Description
bool
hasAllowCredentials
clearAllowCredentials
setAllowCredentials
In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getAllowHeaders
Specifies the content for the Access-Control-Allow-Headers header.
Specifies the content for the Access-Control-Allow-Methods header.
Parameter
Name
Description
var
string[]
Returns
Type
Description
$this
getAllowOriginRegexes
Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
Specifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.
Parameter
Name
Description
var
string[]
Returns
Type
Description
$this
getAllowOrigins
Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
Specifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.
Parameter
Name
Description
var
string[]
Returns
Type
Description
$this
getDisabled
If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.
Returns
Type
Description
bool
hasDisabled
clearDisabled
setDisabled
If true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.
Parameter
Name
Description
var
bool
Returns
Type
Description
$this
getExposeHeaders
Specifies the content for the Access-Control-Expose-Headers header.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Compute V1 Client - Class CorsPolicy (1.35.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.35.0 (latest)](/php/docs/reference/cloud-compute/latest/V1.CorsPolicy)\n- [1.34.0](/php/docs/reference/cloud-compute/1.34.0/V1.CorsPolicy)\n- [1.33.0](/php/docs/reference/cloud-compute/1.33.0/V1.CorsPolicy)\n- [1.32.0](/php/docs/reference/cloud-compute/1.32.0/V1.CorsPolicy)\n- [1.31.0](/php/docs/reference/cloud-compute/1.31.0/V1.CorsPolicy)\n- [1.30.0](/php/docs/reference/cloud-compute/1.30.0/V1.CorsPolicy)\n- [1.29.0](/php/docs/reference/cloud-compute/1.29.0/V1.CorsPolicy)\n- [1.28.0](/php/docs/reference/cloud-compute/1.28.0/V1.CorsPolicy)\n- [1.27.0](/php/docs/reference/cloud-compute/1.27.0/V1.CorsPolicy)\n- [1.26.0](/php/docs/reference/cloud-compute/1.26.0/V1.CorsPolicy)\n- [1.25.0](/php/docs/reference/cloud-compute/1.25.0/V1.CorsPolicy)\n- [1.24.0](/php/docs/reference/cloud-compute/1.24.0/V1.CorsPolicy)\n- [1.23.0](/php/docs/reference/cloud-compute/1.23.0/V1.CorsPolicy)\n- [1.22.1](/php/docs/reference/cloud-compute/1.22.1/V1.CorsPolicy)\n- [1.21.0](/php/docs/reference/cloud-compute/1.21.0/V1.CorsPolicy)\n- [1.20.0](/php/docs/reference/cloud-compute/1.20.0/V1.CorsPolicy)\n- [1.19.0](/php/docs/reference/cloud-compute/1.19.0/V1.CorsPolicy)\n- [1.18.1](/php/docs/reference/cloud-compute/1.18.1/V1.CorsPolicy)\n- [1.17.0](/php/docs/reference/cloud-compute/1.17.0/V1.CorsPolicy)\n- [1.16.2](/php/docs/reference/cloud-compute/1.16.2/V1.CorsPolicy)\n- [1.14.0](/php/docs/reference/cloud-compute/1.14.0/V1.CorsPolicy)\n- [1.13.0](/php/docs/reference/cloud-compute/1.13.0/V1.CorsPolicy)\n- [1.12.1](/php/docs/reference/cloud-compute/1.12.1/V1.CorsPolicy)\n- [1.11.1](/php/docs/reference/cloud-compute/1.11.1/V1.CorsPolicy)\n- [1.10.1](/php/docs/reference/cloud-compute/1.10.1/V1.CorsPolicy)\n- [1.9.1](/php/docs/reference/cloud-compute/1.9.1/V1.CorsPolicy)\n- [1.8.3](/php/docs/reference/cloud-compute/1.8.3/V1.CorsPolicy)\n- [1.7.1](/php/docs/reference/cloud-compute/1.7.1/V1.CorsPolicy)\n- [1.6.1](/php/docs/reference/cloud-compute/1.6.1/V1.CorsPolicy)\n- [1.5.0](/php/docs/reference/cloud-compute/1.5.0/V1.CorsPolicy) \nReference documentation and code samples for the Compute V1 Client class CorsPolicy.\n\nThe specification for allowing client-side cross-origin requests. For more information about the W3C recommendation for cross-origin resource sharing (CORS), see Fetch API Living Standard.\n\nGenerated from protobuf message `google.cloud.compute.v1.CorsPolicy`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Compute \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getAllowCredentials\n\nIn response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.\n\n### hasAllowCredentials\n\n### clearAllowCredentials\n\n### setAllowCredentials\n\nIn response to a preflight request, setting this to true indicates that the actual request can include user credentials. This field translates to the Access-Control-Allow-Credentials header. Default is false.\n\n### getAllowHeaders\n\nSpecifies the content for the Access-Control-Allow-Headers header.\n\n### setAllowHeaders\n\nSpecifies the content for the Access-Control-Allow-Headers header.\n\n### getAllowMethods\n\nSpecifies the content for the Access-Control-Allow-Methods header.\n\n### setAllowMethods\n\nSpecifies the content for the Access-Control-Allow-Methods header.\n\n### getAllowOriginRegexes\n\nSpecifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.\n\n### setAllowOriginRegexes\n\nSpecifies a regular expression that matches allowed origins. For more information, see regular expression syntax . An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes. Regular expressions can only be used when the loadBalancingScheme is set to INTERNAL_SELF_MANAGED.\n\n### getAllowOrigins\n\nSpecifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.\n\n### setAllowOrigins\n\nSpecifies the list of origins that is allowed to do CORS requests. An origin is allowed if it matches either an item in allowOrigins or an item in allowOriginRegexes.\n\n### getDisabled\n\nIf true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.\n\n### hasDisabled\n\n### clearDisabled\n\n### setDisabled\n\nIf true, disables the CORS policy. The default value is false, which indicates that the CORS policy is in effect.\n\n### getExposeHeaders\n\nSpecifies the content for the Access-Control-Expose-Headers header.\n\n### setExposeHeaders\n\nSpecifies the content for the Access-Control-Expose-Headers header.\n\n### getMaxAge\n\nSpecifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header.\n\n### hasMaxAge\n\n### clearMaxAge\n\n### setMaxAge\n\nSpecifies how long results of a preflight request can be cached in seconds. This field translates to the Access-Control-Max-Age header."]]