简体   繁体   中英

Relative File Paths not getting detected when I deploy my app to Google Cloud platform

Locally everything works fine, however as soon as I deploy my app to App Engine. Relative File paths are not getting picked up by google cloud

According to the Where to put your static files ,

You must put your static served files within your app's webapp directory. You can use folders, but remember that all file paths and URIs are relative to the webapp directory.

After you choose a location for the static files, you must define their location in the appengine-web.xml file, using the element.

An example how to configure this is:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <threadsafe>true</threadsafe>
  <runtime>java8</runtime>
  <static-files>
    <include path="/**.html" >
    </include>
  </static-files>
</appengine-web-app>

Also, in the doc: [Serving files directly from your app] ( https://cloud.google.com/appengine/docs/standard/java11/serving-static-files#serving_from_your_application ), it mentions:

To serve static files for Java 11 in the standard environment, you define the handlers in your app.yaml file using either the static_dir or static_files elements.

For example, the following line instructs the browser to load the main.css file:

<link type="text/css" rel="stylesheet" href="/static/css/main.css">

The ./public directory is defined in the static_dir element of the project's app.yaml file:

handlers:
  - url: /favicon\.ico
    static_files: favicon.ico

  - url: /static
    static_dir: public

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM