Google app engine google云应用程序引擎上带有django rest后端的角度前端错误502坏网关
我已经在Google App Engine上部署了带有Django Rest框架后端的angular前端。当我从前端向后端发出请求时,我收到一个错误502坏网关。如果您能帮助我识别问题,我将不胜感激。我试过几次网上推荐,但都不适合我。 这是我的前端应用程序Google app engine google云应用程序引擎上带有django rest后端的角度前端错误502坏网关,google-app-engine,google-cloud-platform,google-app-engine-python,app-engine-flexible,djangoappengine,Google App Engine,Google Cloud Platform,Google App Engine Python,App Engine Flexible,Djangoappengine,我已经在Google App Engine上部署了带有Django Rest框架后端的angular前端。当我从前端向后端发出请求时,我收到一个错误502坏网关。如果您能帮助我识别问题,我将不胜感激。我试过几次网上推荐,但都不适合我。 这是我的前端应用程序 runtime: nodejs12 handlers: - url: / static_files: smis/index.html upload: smis/index.html secure: always
runtime: nodejs12
handlers:
- url: /
static_files: smis/index.html
upload: smis/index.html
secure: always
- url: /
static_dir: smis
secure: always
这是我的后端app.yaml文件
runtime: python38
service: backend
handlers:
- url: /static
static_dir: /static/
secure: always
- url: /.*
script: auto
secure: always
#routing rules
dispatch:
#api
- url: "*/api/*"
service: backend
这是我的dispatch.yaml文件
runtime: python38
service: backend
handlers:
- url: /static
static_dir: /static/
secure: always
- url: /.*
script: auto
secure: always
#routing rules
dispatch:
#api
- url: "*/api/*"
service: backend
url路由中的前导通配符无效。试试这个:
#routing rules
dispatch:
#api
- url: "/api/*"
service: backend
然后,任何以
/api/…
开头的url都将转到python后端我发现我没有设置main.py文件。appengine处理main.py文件中的请求,该文件应位于根目录中。main.py文件的内容可以从wsgi.py文件派生。这是我放在main.py文件中的内容,它对我有用:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smis.settings')
application = get_wsgi_application()
app = application
```