Hi we are using App engine with many new and legacy java services.
we have 1 new frontend angular app and multiple services in java8
we access the application directly using without custom domains
frontend-dot-project-id.appspot.com
legacyapp-dot-project-id.appspot.com
My issue is the dispatch file doesn't affect app URLs with version specified
which broke the apis in the applications if opened in version url
for example :
frontend-dot-project-id.appspot.com/api/v2 => works
ver-dot-frontend-dot-project-id.appspot.com/api/v2 => doesn't work and will take me to frontend application as if there is no dispatch routes deployed
my dispatch.yaml looks something like this:
dispatch:
- url: "*/api/v2/*"
service: api-back
- url: "*/api/v1/*"
service: legacy-back
my app.yaml for the angular app
service: frontend
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(css|eot|gz|html|ico|js|map|png|jpg|svg|ttf|woff|woff2|json)(|\.map))$
static_files: dist/app/\1
upload: dist/app/(.*)(|\.map)
- url: /.*
static_files: dist/app/index.html
upload: dist/app/.*
login: required
skip_files:
- e2e/
- node_modules/
- src/
- coverage
- ^(.*/)?\..*$
- ^(.*/)?.*\.md$
- ^(.*/)?.*\.yaml$
- ^LICENSE
thanks in advance
Related
I have deployed my angular front end with Django Rest Framework backend on Google App Engine. When I make a request to the backend from the frontend I get an error 502 Bad Gateway any help on identifying the problem will be really appreciated. I have tried several online recommendations are not working for me.
This is my front end app.yaml
runtime: nodejs12
handlers:
- url: /
static_files: smis/index.html
upload: smis/index.html
secure: always
- url: /
static_dir: smis
secure: always
This is my backend app.yaml file
runtime: python38
service: backend
handlers:
- url: /static
static_dir: /static/
secure: always
- url: /.*
script: auto
secure: always
This is my dispatch.yaml file
#routing rules
dispatch:
#api
- url: "*/api/*"
service: backend
The leading wildcard in your url routing is invalid. Try this:
#routing rules
dispatch:
#api
- url: "/api/*"
service: backend
Then, any url that begins with /api/... will go to the python backend
I found out I had not set main.py file. App engine handles request in the main.py file which should be in the root directory. The contents of main.py file can be derived from wsgi.py file. This is the content I place in the main.py file and it worked for me:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'smis.settings')
application = get_wsgi_application()
app = application
```
This question already has answers here:
How do I setup routing for react in GAE? Directly routing to react-router-dom routes via URL fails in GAE on basic create-react-app?
(5 answers)
Closed 3 years ago.
Production ReactJS app, integrates Spotify Web Api (https://developer.spotify.com/documentation/web-api/reference-beta/) using Google App Engine: https://widget-dashboard-app.appspot.com/
All of the routes (/settings, /about, /contact) work as expected BUT when a user tries to log in to Spotify, the redirect path /settings/#access_token=[BIG-LONG-TOKEN]&token_type=Bearer&expires_in=3600 results in this error via GAE:
Error: Not Found
The requested URL /settings/ was not found on this server.
My first thought is that I have an issue in my app.yaml file:
# [START runtime]
runtime: python27
api_version: 1
threadsafe: true
# [END runtime]
# [START handlers]
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
- url: /.*
static_files: build/static/\1
upload: build/static/.*
- url: /settings/.*
static_files: build/static/\1
upload: build/static/.*
# [END handlers]
I've scoured the Interwebs in search of what might be the issue for two weeks. I've read all. the. docs.
Actual result should be: User logs in via Spotify's Web API, and is redirected back to https://widget-dashboard-app.appspot.com/settings/#access_token=[BIG-LONG-TOKEN]&token_type=Bearer&expires_in=3600 and their browser will begin playing music within a few seconds. This works in development.
As it's an SPA with your routing handled by the app, you need a catch-all route that lands on your main index.html. So it looks like your wildcard rule should be this:
url: /.*
static_files: build/index.html
upload: build/index.html
I don't think you'll need the /settings/ one
I am trying to set up a vue.js application with the vue router set in "history" mode. I also want to serve my back end APIs from the same app engine application. (e.g., if a user navigates to /some/path/in/the/app and refreshes the page or shares the link, the application will display the expected page)
here is my app.yaml:
runtime: python37
handlers:
- url: /api/.*
secure: always
script: auto
- url: /css
static_dir: www/css
- url: /js
static_dir: www/js
- url: /semantic
static_dir: www/semantic
- url: /img
static_dir: www/img
- url: /
static_files: www/index.html
upload: www/index.html
- url: /.*
static_files: www/index.html
upload: www/index.html
When I try to hit any of my api endpoints, the static index.html file is served instead of the response from the endpoint.
If the last route is omitted (url: /.*), then the api endpoints are served correctly, but the Vue.js app can only be entered from the "/" route and the deep links in the application do not work as expected
I am not looking to have a script in my application to serve the a static file.
note, this question is similar, but none of the answers addressed my situation:
AppEngine app.yaml config for single page apps
The trick was to follow a microservice architecture and split my application into two modules and define the routes in a dispatch.yaml file.
There is a sample project here:
App Engine Modules sample project
I have an angular js app with following structure
app structure
my app folder look like
app folder
the app does use any back end interaction for now but in future its gonna interact with a separate app engine java project . I want to host this angularjs app to google app engine but I am not able to understand the right configuration . I am more confused how do I set up the app.yaml for google app engine ... and is it necessary to have a main.py file as at present I do not have any handler
If I understand correctly, you would like to host a static web page on app engine, specifically an AngularJS app.
You don't need any server side code and can configure your app.yaml as follows:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: www/index.html
upload: www/index.html
- url: /(.*)
static_files: www/\1
upload: www/(.*)
This is assuming you will host your client side code in a www folder and you use a index.html as your index file.
Also take a look at the following guide for hosting a static website [0].
[0] https://cloud.google.com/appengine/docs/standard/python/getting-started/hosting-a-static-website
I have the following yaml file for my Google App Engine website.
application: <my-app-id>
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /sitemap.xml
static_files: static/sitemap.xml
upload: static/sitemap.xml
- url: /
static_files: static/index.html
upload: static/index.html
- url: /
static_dir: static
When I test this app using the local server, the file sitemal.xml is accessible by navigating to.
http://localhost:8080/sitemap.xml
However, when I deploy the app, navigating to the following page just redirects me to index.html (it is impossible to download the xml file).
http://<my-domain>.net/sitemap.xml
http://www.<my-domain>.net/sitemap.xml
Why is the local version behaving differently from the deployed version? What can I do to make the file available in the deployed version?
Google App Engine doesn't support naked domains and most likely it's not being redirected correctly. Try accessing it via: http://www.<my-domain>.net/sitemap.xml to see if that works.
It turns out the problem was caused by domain redirection. If I access the application directly, via the following.
http://<app-id>.appspot.com/
Then everything is fine. Apparently something is broken in the way the domain hosting service handles the redirection.