-
Notifications
You must be signed in to change notification settings - Fork 226
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 next-runtime-env for dynamic envs #515
Conversation
|
Hi I'm just a random guy investigated a few runtime configuration issues today. For curiosity I want to ask, can it be fixed with next.js runtime config without introducing a new dependency? |
@jokester I suspect it'll be an app-specific answer. One of our users opened up #498 initially so we did try that approach, he documents well the drawbacks of using the runtime config (need to disable ASO, can't use standalone builds, can't use RSC... etc). While we did use ASO (it's the default behavior in Next) and we had a build that used standalone builds - we thought we could workaround those issues. In the end disabling ASO (by creating dummy server side props) caused issues with our I couldn't see a cleaner way to disable ASO while avoiding the weird side effects it caused, so the two approaches we had left were to either go down a similar route to Hope that helps! |
So use of |
One related thing that confused me was the different behavior of But I guess with |
packages/app/src/config.ts
Outdated
@@ -11,10 +9,12 @@ export const CLICKHOUSE_HOST = | |||
|
|||
// ONLY USED IN LOCAL MODE | |||
// ex: HDX_LOCAL_DEFAULT_CONNECTIONS='[{"id":"local","name":"Demo","host":"https://demo-ch.hyperdx.io","username":"demo","password":"demo"}]' HDX_LOCAL_DEFAULT_SOURCES='[{"id":"l701179602","kind":"trace","name":"Demo Traces","connection":"local","from":{"databaseName":"default","tableName":"otel_traces"},"timestampValueExpression":"Timestamp","defaultTableSelectExpression":"Timestamp, ServiceName, StatusCode, round(Duration / 1e6), SpanName","serviceNameExpression":"ServiceName","eventAttributesExpression":"SpanAttributes","resourceAttributesExpression":"ResourceAttributes","traceIdExpression":"TraceId","spanIdExpression":"SpanId","implicitColumnExpression":"SpanName","durationExpression":"Duration","durationPrecision":9,"parentSpanIdExpression":"ParentSpanId","spanKindExpression":"SpanKind","spanNameExpression":"SpanName","logSourceId":"l-758211293","statusCodeExpression":"StatusCode","statusMessageExpression":"StatusMessage"},{"id":"l-758211293","kind":"log","name":"Demo Logs","connection":"local","from":{"databaseName":"default","tableName":"otel_logs"},"timestampValueExpression":"TimestampTime","defaultTableSelectExpression":"Timestamp, ServiceName, SeverityText, Body","serviceNameExpression":"ServiceName","severityTextExpression":"SeverityText","eventAttributesExpression":"LogAttributes","resourceAttributesExpression":"ResourceAttributes","traceIdExpression":"TraceId","spanIdExpression":"SpanId","implicitColumnExpression":"Body","traceSourceId":"l701179602"}]' yarn dev:local |
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.
nit: would be great to update this comment as well
export const HDX_LOCAL_DEFAULT_CONNECTIONS = env( | ||
'NEXT_PUBLIC_HDX_LOCAL_DEFAULT_CONNECTIONS', | ||
); | ||
export const HDX_LOCAL_DEFAULT_SOURCES = env( |
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 feel it would be handy if the NEXT_PUBLIC_IS_LOCAL_MODE
is also runtime
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'll leave that to a separate PR, since I think we do different images/serving modes for that anyways.
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.
Thanks for the fix! Tested it on my local and it works like a charm
nit: we probably want to add |
@wrn14897 good point, updated the gitignore |
Disabling ASO had some issues with app navigation clashing with query parameter updates from all our nuqs usage. Switching to
next-runtime-env
and also changing the preset environment variables toNEXT_PUBLIC_HDX_LOCAL_DEFAULT_CONNECTIONS
andNEXT_PUBLIC_HDX_LOCAL_DEFAULT_SOURCES
, which is required for the package, but also makes it nice and clear that these are going to be publicly exposed environment variables.