-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SSR for every pages #2334
Use SSR for every pages #2334
Conversation
This reverts commit ecfcc4d.
Because the props are created at build time, where the |
@@ -15,5 +15,6 @@ export const config = { | |||
"/leaderboard", | |||
"/messages/:path*", | |||
"/chat", | |||
"/chat/:path*", |
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.
Required auth when access "/chat/[id]/
@@ -47,7 +47,7 @@ const styles: Styles = { | |||
}, | |||
body: { | |||
position: "relative", | |||
bg: props.colorMode === "light" ? "gray.50" : colors.dark.bg, |
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.
I fix a small UI issue where the color the not match on light mode.
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.
I am disappointed that next js does not allow for an easier solution for handling this.
maybe they expect everyone to have /api/config
or similar anyway.
arguably speaking, that would still be the easiest solution.
@@ -24,3 +24,4 @@ ENABLE_EMAIL_SIGNIN=true | |||
# inference config | |||
INFERENCE_SERVER_HOST="http://localhost:8000" | |||
INFERENCE_SERVER_API_KEY="6969" | |||
ENABLE_CHAT=true |
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.
it should be disabled by default, otherwise the flag should be DISABLE_CHAT
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 env only used in local or static page (which we don't use any more). So I think it's fine
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.
its fine by me, but, whoever is deploying the project should know that if they just delete the variable, chat will remain enabled, they have to explicitly set the value to false for it to be disabled.
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.
I think those behaviors should be documented instead.
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.
Ok, please don't forget to document it somewhere!
@@ -9,6 +9,7 @@ declare global { | |||
ADMIN_USERS: string; | |||
MODERATOR_USERS: string; | |||
INFERENCE_SERVER_HOST: string; | |||
ENABLE_CHAT: boolean; |
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 should be string, after all, all are environment variables are strings.
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.
I make it boolean to ease the typing stuff. We only compare if(process.env.ENABLE_CHAT), and don't perform any string manipulation so having it as a string doesn't help anything 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.
Then we need to remove all the boolean(...)
from our code because it is redundant?
if (!boolean(process.env.ENABLE_CHAT)) { |
But that would not work, right?
It's ready now._document
only runs once serverside, so this is the expected behavior we want.getInitialProps
run on both server and client. On the client it populates the env wrong, it uses static env from.env
instead of actual env, I'm not sure why.Using SSR is the only way to make it work. This PR is quite similar to #2343 but I expose it to a global var for flexibility (accessing the env outside of react scope) and more performance.