Enable CORS on Google Cloud Server

This issue is similar to issue Acces-Control-Allow-Origin issue.

I am trying to connect to a Google Cloud Instance with a MySQL database.

On Chrome: Error: TypeError: Failed to fetch. Does the server allow CORS?

On Safari: Error: TypeError: Origin https://platform.appgyver.com is not allowed by Access-Control-Allow-Origin.

Looks like this is the procedure - https://cloud.google.com/functions/docs/writing/http

I’m not a developer and its like another language to me. Wondering if anyone has done it and could provide guidance.

It’s this section: https://cloud.google.com/functions/docs/writing/http#handling_cors_requests

If you are using Google Cloud Functions, it’s just a matter of copypasting the sample code to the method returning data from your MySQL DB. Or how have you configured the API for your server?

Hi,

One option is to configure the web server software running on your VM to include an Access-Control-Allow-Origin header in its responses. For example, including an Access-Control-Allow-Origin has information on how to do this for a variety of web server software for google cloud platform training in pune.

Alternatively, you could serve both portions of your website from a single domain name, eliminating the need for cross-origin requests.

Hi,

One option is to configure the web server software running on your VM to include an Access-Control-Allow-Origin header in its responses. For example, including an Access-Control-Allow-Origin has information on how to do this for a variety of web server software.

Alternatively, you could serve both portions of your website from a single domain name, eliminating the need for cross-origin requests.