GCloud Error: Not Found The requested URL was not found on this server - angularjs

I followed this steps to deploy my angular 8 application in Google Cloud
https://medium.com/#karthiksagar/how-to-deploy-angular-8-app-on-google-cloud-platform-gcp-cdd79e5cc5cf
My app.yaml is as follows
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: sofbox-angular/index.html
upload: sofbox-angular/index.html
- url: /
static_dir: sofbox-angular
I have placed the app.yaml file inside dist/ directory as mentioned.
I am able to access the main url- http://www.myridemate.com/
but when clicked on blog the link is not accessible - http://www.myridemate.com/blog
It gives below error
Error: Not Found The requested URL /blog was not found on this server.
Tried adding extra handler for /blog in app.yaml and it didn't work.
This same code is working in my local and also in hostgator - https://www.myridemate.alexvijayraj.com/blog
Not sure what I am missing here. Is there some extra configuration required in app.yaml or anything in GCP?
Error Message in App Engine Logs:
{
"time": "2020-09-17T03:58:28.682252Z",
"severity": "WARNING",
"logMessage": "Static file referenced by handler not found: sofbox-angular/blog"
}

The answer in this thread worked for me. Angular 6 routes not found on Google App Engine
Remember to remove the two handlers that are already on the .yaml file (-url: ...)
handlers:
- url: /(.*\.(js|css|svg|png)(|\.map))$
static_files: dist/\1
upload: dist/(.*)(|\.map)
- url: /.*
static_files: dist/index.html
upload: dist/.*

Related

What is the solution for the error when I deploy pubsub for PHP with App Engine?

I was working on google Pubsub with App Engine, to get notifications from google play about InApp subscriptions status.
When I deploy my app with the command "gcloud app deploy", error message comes:
ERROR: (gcloud.app.deploy) An error occurred while parsing file: [/home/testaccount/php-docs-samples/pubsub/app/app.yaml]
Unable to assign value 'pubsub.js' to attribute 'url':
Value 'pubsub.js' for url does not match expression '^(?:(?!^)/.|..|((.).*(?!$).)$'
in "/home/testaccount/php-docs-samples/pubsub/app/app.yaml", line 6, column 8
My app.yaml file:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: pubsub.js
static_files: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
I have followed the insturctions in the linl:
Writing and Responding to Pub/Sub Messages
I did not modify app.yaml file, I do not know what is going on? I tried to deploy "Hello, World!" for PHP on App Engine" exmaple and it worked.
Please help me to solve it.
url should start with a slash. Try:
- url: /pubsub.js
static_files: pubsub.js
After a week searching about why I get HTTP error 500 (Internal Server Error) when I browse https://testproject.uc.r.appspot.com/, I got the reason, it was from app.yaml file, all errors came from php version.
Old app.yaml:
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: index.php
env_variables:
GOOGLE_PROJECT_ID: "testproject"
New app.yaml:
runtime: php72
handlers:
- url: /pubsub.js
static_files: pubsub.js
upload: pubsub.js
- url: /.*
script: auto
env_variables:
GOOGLE_PROJECT_ID: "testproject"
Thank God.

Vue production URL redirection returning 404 on gae

I have a vue application that I want to deploy to google app engine. I have deployed it and everything works as it should but when I manually enter in a url the app responds with a 404. Is there any way I can setup the app.yaml to allow for the redirection to the SPA from a url?
# GAE yml setup
runtime: python27
api_version: 1
threadsafe: true
# URL handlers
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
- url: /(.*)
static_files: dist/\1
upload: dist/(.*)
- url: .*
static_files: dist/index.html
upload: dist/index.html
# GAE has a limit of 10,000 files so ignore node_modules and anything else thats not neccassary
skip_files:
- node_modules/
- .gitignore
- src/
- public/
- babel.config.js
- ^(.*/)?\..*$
How can I redirect with handlers to a specific page on the SPA?
Here is an example about what you are trying to achieve.
This specific solution (redirect all URLs to a single URL) works in two steps, modifying your app.yaml and adding some source in the .py file.
In the app.yaml, by adding the handlers: "App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript."
handlers:
- url: /.*
script: main.py
And in the .py file, by adding the 'rule' to redirect.
class AllHandler(webapp.RequestHandler):
def get(self):
self.redirect("http://example.com", True)
application = webapp.WSGIApplication([('/.*', AllHandler)])

I am hosting my website (php files) in GAE. The app.yaml file is not routing the pages of my site. Error: No Found

My site has 8 pages and it is written in php: https://intercultural.appspot.com After deploying in GAE, it can load and dislpay the index.php page. However, does not display the other pages when I click on other links: Error: No Found The requested URL /file.php was not found on this server.
Here is the directory of my file: hightlighted in blue are the pages of my site.
enter image description here
Here is my app.yaml file:
runtime: php72 </b>
handlers:
# Serve a directory as a static resource.
- url: /styles
static_dir: styles
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
# Serve your app through a front controller at index.php or public/index.php.
- url: /(.+\.php)$
static_files: static/\1
upload: /(.+\.php)$
# I add the "/" to url bellow as suggested but still get same error
- url: /.*
script: auto
secure: always
Although it displays the site address in the browser, it says: Error: No Found The requested URL /file.php was not found on this server.
What is missing in the app.yaml file to route properly to the other pages of my site?
The URL for your final entry in the app.yaml should be url: /.* (with slash). This is necessary to match URLs of https://intercultural.appspot.com/*. You can see an example in the app.yaml reference.
I already fixed it.
The main problem was in the php version. I thought my code was written in php7.2 but actually it was php5.5, hence, the app.yaml didn't work properly.
Here is the app.yaml file:
This is my app.yaml file
runtime: php55
api_version: 1
handlers:
- url: /styles
static_dir: styles
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
application_readable: true
- url: /
script: index.php
secure: always
- url: /(.+\.php)$
script: \1
secure: always

URLs not found after deploying create-react-app build to Google Cloud Platform

I've uploaded a create-react-app build (with an app.yaml file) to a GCP bucket. The app has then been deployed on a App Engine instance using the cloud shell.
Going to the app's root URL works fine. But going to example.com/anything returns the following error:
Error: Not Found
The requested URL /anything was not found on this server.
App.yaml file looks like this:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /(.*\.(html|css|js))
static_files: build/\1
upload: build/(.*\.(html|css|js))
- url: /
static_files: build/index.html
upload: build/index.html
You don't have a handler for /anything. If you want a catch-all url, use regex type handler:
- url: /.*
static_files: build/index.html
upload: build/index.html
or, if you want to serve them anything.html as a static file, put it in your build dir, and navigate to /anything.html. Your first handler is set up to map that url.

404 page doesn't show when accessing a missing file in a static directory

I'm working on porting my blog from GitHub pages to Google App Engine. I've set up my app.yaml as follows.
runtime: python27
api_version: 1
version: 5
threadsafe: yes
handlers:
- url: /api/.*
script: main.app
- url: /
static_files: src/_site/index.html
upload: src/_site/index.html
- url: /(.*)/
static_files: src/_site/\1/index.html
upload: src/_site/*.*
- url: /(.*)
static_files: src/_site/\1
upload: src/_site/(.*)
error_handlers:
- file: static/404.html
You can get to my 404 page directly by going to http://joshuasnidercom.appspot.com/404.html and you can get to by accessing a missing page that the flask app handles like http://joshuasnidercom.appspot.com/api/invalidurl, but going to any page that is covered by the static files like http://joshuasnidercom.appspot.com/nonexistentpage just shows a Error: Not Found The requested URL /nonexistentpage was not found on this server. error.
What should I be doing differently?
I believe you need to create an error handler in your views file.
You can do this with the following code:
#app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"),404
You can also replace 404 with 500, 403, etc,for other errors.

Resources