Créer un fichier nginx.conf personnalisé compatible avec le CORS

Comme décrit dans la section Ajouter la compatibilité CORS à ESP, vous pouvez configurer Extensible Service Proxy (ESP) afin d'assurer la compatibilité avec CORS. Si les options ESP ne permettent pas la compatibilité avec le mécanisme CORS requise par votre application, vous pouvez ajouter les options CORS au fichier de configuration ESP nginx.conf.

Ajouter les options CORS à nginx.conf

Pour ajouter les options CORS, procédez comme suit :

  1. Commencez avec un fichier nginx.conf contenant la configuration requise par Cloud Endpoints. Vous pouvez commencer avec l'exemple nginx.conf ou, si vous avez déjà déployé ESP, vous pouvez vous connecter en SSH au conteneur ESP et copier le fichier nginx.conf à partir du répertoire /etc/nginx/endpoints/.

  2. Ajoutez les options CORS requises par votre application au fichier nginx.conf. Vous pouvez utiliser l'exemple CORS on NGINX (CORS sur NGINX) comme point de départ.

  3. Démarrez ESP en spécifiant l'option --nginx_config avec le chemin d'accès au fichier personnalisé nginx.conf.

Étapes suivantes