0

enter image description here

Dear all,

My API works locally when I run it on localhost but it does not work when I upload a Docker image to Google Cloud. The error is attached in a picture.

Here is my Dockerfile:

FROM python:3.8-slim-buster ENV APP_HOME /app WORKDIR $APP_HOME COPY . ./ COPY requirements.txt ./ RUN pip install -r requirements.txt COPY . . CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app 

I am using flask_restx with annotations to have Swagger. When I go to https://[API_URL]//swagger.json, I get the following response:

{"swagger": "2.0", "basePath": "/", "paths": {"/my models/": {"post": {"responses": {"200": {"description": "Success"}}, "summary": "Returns parameters", "operationId": "Get parameters.", "parameters": [{"name": "problem_name", "in": "query", "type": "string", "required": true, "enum": ["aa", "bb"], "collectionFormat": "multi"}, {"name": "type", "in": "query", "type": "string", "required": true, "enum": ["random"], "collectionFormat": "multi"}, {"name": "th", "in": "query", "type": "integer", "required": true, "enum": [10, 20], "collectionFormat": "multi"}, {"name": "num", "in": "query", "type": "integer", "required": true, "default": 1}], "tags": ["models"]}}}, "info": {"title": "API", "version": "1.0", "description": "API"}, "produces": ["application/json"], "consumes": ["application/json"], "tags": [{"name": "models", "description": "models"}], "responses": {"ParseError": {"description": "When a mask can't be parsed"}, "MaskError": {"description": "When any error occurs on mask"}}} 

Would you point me in the right direction? Creating a Docker image is successful, as well as uploading it to Google Cloud.

Thanks.

3
  • The response you get when using HTTPS url is your swagger.json which is the correct response. Why fetch with HTTP? All Cloud Run services have stable HTTPS url cloud.google.com/run/docs/triggering/https-request Commented Mar 17, 2021 at 3:24
  • You have mixed-content issue. This is happening when you have HTTPS session trying to consume HTTP endpoint. It's perfectly fine for the browser to start an http session and consume https but the opposite is not acceptable since there is a chance that you will expose secrets from the secure session trough the unsecured endpoint. Switch all endpoints to HTTPS Commented Mar 17, 2021 at 6:14
  • Thanks. Would you hint how to change them? i tried these solutions but none worked for me. One worked locally - I saw it running on https but on gcloud there was still the same error after reuploading. stackoverflow.com/questions/32237379/… Commented Mar 17, 2021 at 20:06

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.