Wie in Hinzufügen von CORS-Unterstützung zu ESP beschrieben, können Sie Extensible Service Proxy (ESP) zur Unterstützung von CORS konfigurieren.
Wenn die ESP-Optionen nicht die von Ihrer Anwendung benötigte CORS-Unterstützung bieten, können Sie die CORS-Optionen der ESP-Konfigurationsdatei nginx.conf hinzufügen.
Hinzufügen der CORS-Optionen zu nginx.conf
So fügen Sie die CORS-Optionen hinzu:
Beginnen Sie mit einer nginx.conf-Datei, die die für Cloud Endpoints erforderliche Konfiguration enthält. Sie können mit dem Beispiel nginx.conf beginnen, oder wenn Sie ESP bereits bereitgestellt haben, können Sie eine SSH-Verbindung zum ESP-Container herstellen und die nginx.conf-Datei aus dem /etc/nginx/endpoints/-Verzeichnis kopieren.
Fügen Sie die von Ihrer Anwendung benötigten CORS-Optionen zu nginx.conf hinzu. Sie können das Beispiel CORS on NGINX als Ausgangspunkt verwenden.
Starten Sie ESP mit der Option --nginx_config mit dem Pfad zur benutzerdefinierten Datei nginx.conf.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[[["\u003cp\u003eYou can configure the Extensible Service Proxy (ESP) to support CORS, as described in the documentation for adding CORS support to ESP.\u003c/p\u003e\n"],["\u003cp\u003eIf ESP options don't meet your application's CORS needs, you can customize CORS by adding options directly to ESP's \u003ccode\u003enginx.conf\u003c/code\u003e configuration file.\u003c/p\u003e\n"],["\u003cp\u003eTo add custom CORS options, begin with a \u003ccode\u003enginx.conf\u003c/code\u003e file required by Cloud Endpoints, such as the sample one, or by retrieving it from a deployed ESP container.\u003c/p\u003e\n"],["\u003cp\u003eAfter adding your custom CORS settings to \u003ccode\u003enginx.conf\u003c/code\u003e, start ESP using the \u003ccode\u003e--nginx_config\u003c/code\u003e option, pointing to your modified configuration file.\u003c/p\u003e\n"]]],[],null,[]]