This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 11. Allowing JavaScript-based access to the API server from additional hosts
11.1. Allowing JavaScript-based access to the API server from additional hosts Copier lienLien copié sur presse-papiers!
The default OpenShift Container Platform configuration only allows the web console to send requests to the API server.
If you need to access the API server or OAuth server from a JavaScript application using a different hostname, you can configure additional hostnames to allow.
Prerequisites
-
Access to the cluster as a user with the
cluster-admin
role.
Procedure
Edit the
APIServer
resource:oc edit apiserver.config.openshift.io cluster
$ oc edit apiserver.config.openshift.io cluster
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
additionalCORSAllowedOrigins
field under thespec
section and specify one or more additional hostnames:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The hostname is specified as a Golang regular expression that matches against CORS headers from HTTP requests against the API server and OAuth server.
NoteThis example uses the following syntax:
-
The
(?i)
makes it case-insensitive. -
The
//
pins to the beginning of the domain and matches the double slash followinghttp:
orhttps:
. -
The
\.
escapes dots in the domain name. -
The
(:|\z)
matches the end of the domain name(\z)
or a port separator(:)
.
- Save the file to apply the changes.