Google应用引擎:未找到处理程序引用的静态文件



我没有网络托管的经验,我已经尝试了几天让我的(Spring Boot + Angular)应用程序启动和运行。请帮助!

我弄不清请求的路由。下面是我的服务器端应用程序的结构:
src
main
appengine
app.yaml
java
resources
pom.xml

当我部署我的应用程序时,我使用maven-resources-pluginng build并将我的前端(在不同的文件夹中)复制到${basedir}/target/classes/static

现在这里是我的app.yaml处理程序:

handlers:
# Direct these to the server's endpoints
- url: /api/.*
script: auto
# Direct these to index.html and let the frontend routes do their thing
- url: /.*
static_files: static/front/index.html # this does not work
upload: static/front/index.html       # this does not work

当我试图到达mywebsite.com/some-page时,请求被路由到我的服务器,由于/some-page端点不存在,我得到"请求的URL/未在此服务器上找到";处理程序引用的静态文件未找到">

我的问题是,我应该把什么路径在这里static_files,所以我的请求不包含/api/不都路由到服务器应用程序?

此外,我试图将app.yaml移动到项目根,使这更容易,但部署(mvn package appengine:deploy)失败,因为它没有找到文件/src/main/appengine/app.yaml

编辑:为了它的价值,这是index.html的位置当我探索JAR:

my-website.jar
META-INF
BOOT-INF
classes
com
purrfectdoodle
back
service <----------- These are the project packages
model
repository
...
static
front
index.html <---------- HERE

应用程序的app.yaml中的错误经常导致找不到处理程序引用的错误静态文件。它基本上意味着app.yaml的静态文件处理程序之一正在转移到一个不存在的文件或命名错误的文件。如果您使用一种技术来区分文件和目录,建议将其作为一种策略。您可以通过声明所有文件名必须有扩展名(而文件夹则不可以)来实现类似的目的。在他们的名字里):

/optional/path/folder/- serve index.html in
- url: /(.*)/ static_files: public/1/index.html upload: public/.*/index.html/可选/道路/的名字。扩展=比;
- url: /((.*/)*[^/]+.[^/]+)$ static_files: public/1 upload: public/.*
其他都是文件夹-在
- url: /(.*)$ static_files: public/1/index.html upload: public/.*/index.html

内提供index.html请注意,所有这些都取决于您的目录结构。顺序很重要,/的使用也很重要。+代替/。*对于后者,请求/将被路由到main.app

这里也有关于app.yaml配置[1]和结构化web服务文档[2]的参考。

[1]: https://cloud.google.com/appengine/docs/standard/python3/config/appref

[2]: https://cloud.google.com/appengine/docs/standard/java-gen2/configuration-files

最新更新