-
Notifications
You must be signed in to change notification settings - Fork 87
feat(sendHtml): allow custom error page #281
Conversation
This allows ONE_FALLBACK_URL to be given in order to define a custom error page.
📊 Bundle Size Report
|
@JamesSingleton Could we add documentation for |
Yeah, I was going to wait to add the docs until after the reviews in the off chance that implementation changes based on feedback. I mentioned that in the description, I wish we could add "tasks" to be completed. |
src/server/middleware/sendHtml.js
Outdated
${message} | ||
</p> | ||
</div> | ||
const fallbackUrl = process.env.ONE_FALLBACK_URL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, we will need to have this environment variable validated alongside the other env variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ONE_FALLBACK_URL to runTime.js
src/server/middleware/sendHtml.js
Outdated
@@ -69,30 +81,36 @@ export function renderStaticErrorPage(res) { | |||
message = 'Sorry, we are unable to load this page at this time.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to have this custom too? especially with internationalization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly in another PR, this PR is just to allow a custom error page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is meant to be the final catch all. we can not add anything that could risk an error being thrown here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we provide, a default option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally if they wanted a custom message they would just use a custom error page right?
src/server/middleware/sendHtml.js
Outdated
@@ -69,30 +81,36 @@ export function renderStaticErrorPage(res) { | |||
message = 'Sorry, we are unable to load this page at this time.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is meant to be the final catch all. we can not add anything that could risk an error being thrown here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after offline discussion, warn don't throw when failing to update error page.
This is to prevent one-app failing to start when pods scale / restart due to an external factor "e.g network issue fetching error page"
prod-sample/sample-modules/frank-lloyd-root/0.0.0/src/config.js
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from a couple of optionals suggestions
to the name of the tests this looks really good 👍
5c5d4da
Description
This allows ONE_FALLBACK_URL to be given in order to define a custom
error page.
So this will require documentation on it, but I wanted to wait for approvals just in the off chance that the implementation changes due to reviews.
Motivation and Context
Allow someone to override the default error page.
How Has This Been Tested?
This was tested locally returning
renderStaticErrorPage(res)
and testing with different scenarios. Also, unit tests.Types of Changes
Checklist:
What is the Impact to Developers Using One App?
They can now provide
ONE_FALLBACK_URL
to be used as the error page instead of the default.