Google App Engine – 404 只对 .js 文件有效。

huangapple go评论48阅读模式
英文:

Google App Engine - 404 but only for .js files

问题

I have a nuxt app deployed to GAE. My previous deploy happened about a month ago, the app was working as expected after that. I made some text changes recently, but after deploying saw that the app is not working as all the requests against .js files returned with 404.

My app.yml looks like the following:

runtime: nodejs14
instance_class: F2

handlers:
  - url: /_nuxt
    static_dir: .nuxt/dist/client
    secure: always

  - url: /(.*\.(gif|png|jpg|ico|txt))$
    static_files: static/
    upload: static/.*\.(gif|png|jpg|ico|txt)$
    secure: always

  - url: /.*
    script: auto
    secure: always

env_variables:
  HOST: '0.0.0.0'
  NODE_ENV: 'staging'

I've double-checked in GAE's debugger that the .js files are there in the .nuxt/dist/client folder. I have an additional file there /.nuxt/dist/client/LICENSE, and GAE returns that without any problem when triggering a request <domain>/_nuxt/LICENSE. So it's just the .js files GAE doesn't want to serve...

Does anyone have any suggestion?

Thanks in advance!

Update:
I cannot see any error other than the fact of the 404 response. Here're the logs and how dev-tools looks like.

英文:

I have a nuxt app deployed to GAE. My previous deploy happened about a month ago, the app was working as expected after that. I made some text changes recently, but after deploying saw that the app is not working as all the requests against .js files returned with 404.

My app.yml looks like the following:

runtime: nodejs14
instance_class: F2

handlers:
  - url: /_nuxt
    static_dir: .nuxt/dist/client
    secure: always

  - url: /(.*\.(gif|png|jpg|ico|txt))$
    static_files: static/
    upload: static/.*\.(gif|png|jpg|ico|txt)$
    secure: always

  - url: /.*
    script: auto
    secure: always

env_variables:
  HOST: &#39;0.0.0.0&#39;
  NODE_ENV: &#39;staging&#39;

I've double checked in GAEs debugger that the .js files are there in the .nuxt/dist/client folder. I have an additional file there /.nuxt/dist/client/LICENSE, and GAE returns that without any problem when triggering a request &lt;domain&gt;/_nuxt/LICENSE. So it's just the .js files GAE doesn't want to serve...

Does anyone any suggestion?

Thanks in advance!

Update:
I cannot see any error other than the fact of the 404 response. Here're the logs and how dev-tools looks like.
Google App Engine – 404 只对 .js 文件有效。
Google App Engine – 404 只对 .js 文件有效。

答案1

得分: 1

如果您正在使用自定义服务器与Nuxtjs,我的解决方案是在app.yaml中删除这两个处理程序。

由于某种原因,我的部署今天失败了,并且已经修复了。

handlers:
  # - url: /_nuxt
  #   static_dir: .nuxt/dist/client
  #   secure: always

  # - url: /(.*\.(gif|png|jpg|ico|txt))$
  #   static_files: static/
  #   upload: static/.*\.(gif|png|jpg|ico|txt)$
  #   secure: always

  - url: /.*
    script: auto
    secure: always
英文:

If you're using custom server with your Nuxtjs, my solution is removing these two handlers in app.yaml.

For some reason my deployment failed today and got it fixed.

handlers:
  # - url: /_nuxt
  #   static_dir: .nuxt/dist/client
  #   secure: always

  # - url: /(.*\.(gif|png|jpg|ico|txt))$
  #   static_files: static/
  #   upload: static/.*\.(gif|png|jpg|ico|txt)$
  #   secure: always

  - url: /.*
    script: auto
    secure: always

huangapple
  • 本文由 发表于 2023年5月11日 00:34:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76220749.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定