Search code examples
python-2.7google-app-enginegoogle-cloud-platformangular7

App yaml configuration issue when deploying angular 7 website and google app engine API's


I am trying to deploy an Angular7 application in Google App Engine with backend endpoints in python2.7.And here I am getting handlers error:

Static file referenced by handler not found: dist/_ah/api/sampleApi/v1/users

Both Angular dist folder and API's when configured in app.yaml fails.

If API's configuration is removed from app.yaml Angular website works. If Angular dist is removed from app.yaml API's work from the postman.

handlers:     
- url: /        
  static_files: dist/index.html         
  upload: dist/index.html      
  secure: always       
- url: /       
  static_dir: dist      
- url: /_ah/api/.*    
  script: sample.api   

My project Structure is:

project-folder   
   -- app.yaml    
   -- endpoint source code files    
   -- dist folder (for angular)    

Solution

  • I figured it out by adding two more extra handlers to my app.yaml file:

    • url: /(..(html|gif|png|jpg|js))$
      static_files: dist/\1
      upload: dist/.
      .(html|gif|png|jpg|js)$
      secure: always
    • url: /img
      static_dir: dist/assets
      secure: always

    It's working now.