-3

I have some issues when I tried to practice using Google cloud. I'm trying to deploy Flask as a back-end server to Google cloud, and Angular as a front-end app.

However, there is a message 500 Server Error, and CORS blocking for Angular app request to Flask server. This happens after I deployed both in the separate Google cloud projects.

I'm not sure that I should deploy the server in production mode or not, but I didn't do that. Could it be possible that you will give me suggestion?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • Provide more information on how the error occurred. Maybe some header data or a screenshot of the request and response would help – Lasithds Mar 23 '20 at 08:51

1 Answers1

1

You should enable CORS on your flask backend hosted on GCP.

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served

Check theses resources :

For example:

app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": ["http://localhost:4200", "URL_ON_GCP"]}})

where URL_ON_GCP is the URL of your hosted backend, for example:

Thierry Falvo
  • 5,892
  • 2
  • 21
  • 39