Skip to content

Commit 43960cb

Browse files
fix(web): migrate server env variables to T3 Env
Ultra-worked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 78adbfe commit 43960cb

3 files changed

Lines changed: 27 additions & 21 deletions

File tree

apps/web/src/instrumentation.node.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ import { resourceFromAttributes } from "@opentelemetry/resources";
55
import { NodeSDK } from "@opentelemetry/sdk-node";
66
import { TraceIdRatioBasedSampler } from "@opentelemetry/sdk-trace-base";
77
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
8-
9-
const serviceName = process.env.OTEL_SERVICE_NAME || "web";
10-
const sampleRate = Number.parseFloat(process.env.OTEL_SAMPLE_RATE || "0.1");
8+
import { env } from "@/config/env";
119

1210
const sdk = new NodeSDK({
1311
instrumentations: [new HttpInstrumentation(), new FetchInstrumentation()],
1412

1513
resource: resourceFromAttributes({
16-
[ATTR_SERVICE_NAME]: serviceName,
14+
[ATTR_SERVICE_NAME]: env.OTEL_SERVICE_NAME,
1715
}),
1816

19-
sampler: new TraceIdRatioBasedSampler(sampleRate),
17+
sampler: new TraceIdRatioBasedSampler(env.OTEL_SAMPLE_RATE),
2018

2119
traceExporter: new TraceExporter(),
2220
});

apps/web/src/lib/api-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import axios from "axios";
2+
import { env } from "@/config/env";
23

34
export const apiClient = axios.create({
4-
baseURL: process.env.NEXT_PUBLIC_API_URL || "http://localhost:8000",
5+
baseURL: env.NEXT_PUBLIC_API_URL,
56
timeout: 30000,
67
headers: {
78
"Content-Type": "application/json",

apps/web/src/lib/auth.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
import { betterAuth } from "better-auth";
22
import { nextCookies } from "better-auth/next-js";
3+
import { env } from "@/config/env";
34

45
export const auth = betterAuth({
5-
baseURL: process.env.BETTER_AUTH_URL,
6-
secret: process.env.BETTER_AUTH_SECRET!,
6+
baseURL: env.BETTER_AUTH_URL,
7+
secret: env.BETTER_AUTH_SECRET,
78
socialProviders: {
8-
google: {
9-
clientId: process.env.GOOGLE_CLIENT_ID!,
10-
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
11-
},
12-
github: {
13-
clientId: process.env.GITHUB_CLIENT_ID!,
14-
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
15-
},
16-
facebook: {
17-
clientId: process.env.FACEBOOK_CLIENT_ID!,
18-
clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
19-
},
9+
google: env.GOOGLE_CLIENT_ID
10+
? {
11+
clientId: env.GOOGLE_CLIENT_ID,
12+
clientSecret: env.GOOGLE_CLIENT_SECRET,
13+
}
14+
: undefined,
15+
github: env.GITHUB_CLIENT_ID
16+
? {
17+
clientId: env.GITHUB_CLIENT_ID,
18+
clientSecret: env.GITHUB_CLIENT_SECRET,
19+
}
20+
: undefined,
21+
facebook: env.FACEBOOK_CLIENT_ID
22+
? {
23+
clientId: env.FACEBOOK_CLIENT_ID,
24+
clientSecret: env.FACEBOOK_CLIENT_SECRET,
25+
}
26+
: undefined,
2027
},
2128
plugins: [nextCookies()],
2229
session: {
@@ -26,5 +33,5 @@ export const auth = betterAuth({
2633
strategy: "jwe",
2734
},
2835
},
29-
trustedOrigins: [process.env.BETTER_AUTH_URL || "http://localhost:3000"],
36+
trustedOrigins: [env.BETTER_AUTH_URL],
3037
});

0 commit comments

Comments
 (0)