Tengo problemas con mi archivo app.yaml: tengo una aplicación de una sola página (aplicación Angular2) en AppEngine con un tiempo de ejecución de python, pero los enlaces profundos no se enrutan correctamente. Aquí está mi archivo app.yaml:
runtime: python27 api_version: 1 threadsafe: true skip_files: - ^(.*/)?app\.yaml - ^(.*/)?app\.yml - ^(.*/)?#.*# - ^(.*/)?.*~ - ^(.*/)?.*\.py[co] - ^(.*/)?.*/RCS/.* - ^(.*/)?\..* - ^(.*/)?tests$ - ^(.*/)?test$ - ^test/(.*/)? - ^COPYING.LESSER - ^README\..* - \.gitignore - ^\.git/.* - \.*\.lint$ - ^fabfile\.py - ^testrunner\.py - ^grunt\.js - ^node_modules/(.*/)? - ^src/(.*/)? - ^e2e/(.*/)? handlers: - url: / static_files: dist/index.html upload: dist/index.html - url: /(.*) static_files: dist/\1 upload: dist/(.*)
Recibo el siguiente error cuando voy directamente a un enlace profundo:
Supongo que el segundo controlador es el que lo está haciendo, pero ¿cómo escribo mis controladores para enviar todo a index.html excepto los activos? Aquí está mi directorio dist:
Ah, sí, yo tenía el mismo problema. Aquí está el app.yaml que estoy usando para una aplicación Angular2 en Appengine:
runtime: python27 api_version: 1 threadsafe: true handlers: - url: /api/.* script: main.app # All files that can be compiled in angular. Luckily, they all have suffixes. - url: /(.*\.(css|eot|gz|html|ico|js|map|png|svg|ttf|woff|woff2)) static_files: ../client/dist/\1 upload: ../client/dist/(.*\.(css|eot|gz|html|ico|js|map|png|svg|ttf|woff|woff2)) # Site root, plus anything else, like deep urls # Make this be secure, otherwise oauth redirect won't work if they want to us with http:// - url: /.* static_files: ../client/dist/index.html upload: ../client/dist/index.html secure: always expiration: "15m" libraries: - name: webapp2 version: "2.5.2"
Para manejar enlaces profundos, necesita una regla general al final para servir siempre index.html . Sin embargo, antes de eso, necesita una regla que mapee todo su contenido estático, estoy haciendo la mía por la presencia de un sufijo, pero otra forma de hacerlo es nombrando específicamente todos los archivos y directorios que son sus activos estáticos.