I hosted my static web pages on Google App Engine (Java). It does not have any server side coding.
I used HTML5 Boilerplate code as my base. It has page called 404.html. I would like to show this 404.html page when there is page not found error.
How can I show a custom 404 page in Google App engine?
In Java you can set up error handlers in your web.xml file (which is located in the app's WAR under the WEB-INF/ directory).
<error-page>
<error-code>500</error-code>
<location>/errors/servererror.jsp</location>
</error-page>
You can set custom error responses in your app.yaml file.
Related
I'm currently working on a full-stack project mainly using ReactJS and AWS Amplify. I've successfully deployed the website but the URL routings only seem to work if I redirect from the home page. I can only load the home page www.website.com but I try to manually type in www.website.com/login/, it gives me this message
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>B2173BDEE0658858</RequestId>
<HostId>
TRevHdaqGZYTUxU9W1wXc3CQccfLeznHlYLcbuF+Wr511FVmOPFBp4tpyccJ2t5QMVpvYygNNb4=
</HostId>
</Error>
I've looked up solutions from other StackOverflow pages but it didn't seem to solve the issue.
I have tried adding a redirect rule in the AWS console provided (Getting 403 ACCESS DENIED error when deploying React Web app on AWS Amplify) but the issue persists. Is there a way to fix this?
You have to set up a 404 (page not found) redirect on the AWS Amplify to point on the index.html.
React App is SPA (Single Page App) it has its own routing, and on the AWS side, all other routes except base path will return 404, because they don't exist on the server-side.
Once you setup 404 to points on your React application again, React router will handle the routing.
Check: docs.aws.amazon.com/amplify/latest/userguide/redirects.html and pay attention to 404 redirections.
I have hosted my react app on AWS Amplify. On trying to access a protected route of the application I am getting the following error on screen This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>3C8377104116CA48</RequestId>
<HostId>nL3bDs+kXEWE8uBFPTLkFLpRg6CCmKfejftWs5wmTWYO6K6WDzpwsDXJCFTK0EFhjJdaHECfuos=</HostId>
</Error>
How do I resolve this?
Route redirects and rewrites has special configuration for a deployed AWS Amplify app. Check the
AWS Amplify Console > App Settings > Rewrites and Redirects
Configuring a rewrite rule fixed this issue for me.
My rule looks like so:
Source -
</^[^.]+$|\.(?!(css|yaml|gif|ico|jpg|js|png|txt|svg|woff2|woff|ttf|map|json)$)([^.]+$)/>
Target -
/index.html
Type -
200 (Rewrite)
Detailed description is here - https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html
I am hosting a react website on Google cloud bucket. The bucket is exposed to public internet and cname is pointed to c.storage.googleapis.com. and web settings is also updated to load index.html. Inside bucket there is app.yaml and build folder where index.html is present.
But when i browse my domain(www.gobillion.co) - which ideally shall load my hosted website. It is instead giving no such key error. What might be the problem here ?
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>
Thanks in advance.
I have a react app and was getting this error
I fixed this by setting in the buckets "Edit Website Configuration"
"Error (404 not found) page" to "index.html"
so when it cant find a path it serves the app page
I have a google app engine project (go) and don't really like the default 404 page. I've built a custom 404.html page and placed it in my root but can't for the life of me work out how to redirect 404 errors to this custom page. Any ideas?
I would recommend to read the documentation about app.yaml Reference, error_handlers
Example
error_handlers:
- file: default_error.html
- error_code: over_quota
file: over_quota.html
I've previously worked with J2EE where it's possible to add this configuration to web.xml
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/error</location>
</error-page>
The effect of the above code is that if an unhanded exception is thrown, it will be passed to the /error page, which will be shown to the user.
Is there a way to do something similar to this when my Go web application panics on Google App Engine?
Yes, see Custom error responses:
When certain errors occur, App Engine serves a generic error page. You
can configure your app to serve a custom static file instead of these
generic error pages, so long as the custom error data is less than 10
kilobytes. You can set up different static files to be served for each
supported error code by specifying the files in your app's app.yaml
file. To serve custom error pages, add a error_handlers section to
your app.yaml, as in this example:
error_handlers:
- file: default_error.html
- error_code: over_quota
file: over_quota.html