我已经在Google App Engine上部署了一个带有2个服务的PHP应用程序: admin和api。
我使用配置文件来路由请求。
我的问题是我不能将请求路由到我的服务。仅设置为默认值。
结构是这样的:
|-- admin
|-- public
|-- index.php
|-- admin.yaml
|-- API
|-- api
|-- index.php
|-- api.yaml
|-- dispatch.yaml
|-- index.phpdispatch.yaml:
dispatch:
# Send all api traffic to the API.
- url: "*/API/api/*"
service: api
# Send all admin traffic to the admin.
- url: "*/admin/public/*"
service: admin
# Default service serves simple hostname request.
- url: "*/*"
service: defaultadmin/admin.yaml:
runtime: php73
service: admin
handlers:
- url: /admin/public/.*
script: /admin/public/index.phpApi.yaml接口:
runtime: php73
service: api
handlers:
- url: /API/api/.*
script: /API/api/index.phpindex.php:echo "Not found";
管理/公共/索引.php:echo "Welcome to admin service";
api接口:echo "Welcome to api service";
当我发送一个请求:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com或https://PROJECT_ID.REGION_ID.r.appspot.com时,响应是预期的: Not found。
但是当我发送一个请求:https://SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com/API/api/或https://PROJECT_ID.REGION_ID.r.appspot.com/API/api/时,响应是一个error code 500,而不是:Welcome to api service。
问题出在哪里?配置?请求urls?其他的?
发布于 2021-11-11 13:22:02
问题出在yaml文件中:
新的dispatch.yaml
dispatch:
# Send all api traffic to the API.
- url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
service: api
# Send all admin traffic to the admin.
- url: "SERVICE_ID-dot-PROJECT_ID.REGION_ID.r.appspot.com"
service: admin
# Default service serves simple hostname request.
- url: "PROJECT_ID.REGION_ID.r.appspot.com"
service: default新的admin/admin.yaml:
runtime: php73
service: admin
handlers:
- url: /.*
script: /admin/public/index.php新接口/api.yaml:
runtime: php73
service: api
handlers:
- url: /.*
script: /API/api/index.php不再有路由问题。
https://stackoverflow.com/questions/69826066
复制相似问题