import { AtomHttpApi } from '@effect-atom/atom-react'
import { HttpClient, HttpClientRequest } from '@effect/platform'
import { Effect, Layer } from 'effect'
// ... other app-specific imports like GroupXXXApi, AuthService
const GroupXXXApiLive = Layer.effect(
HttpClient.HttpClient,
Effect.gen(function* () {
const client = yield* HttpClient.HttpClient
const auth = yield* AuthService // Assuming you have an auth service
return client.pipe(
// This creates a new client that won't add tracing headers
HttpClient.withTracerPropagation(false),
// You can still chain other customizations, like adding auth tokens
HttpClient.mapRequestEffect(request =>
Effect.gen(function* () {
// ... your auth logic to get a token and add it to the request ...
const token = yield* auth.getAccessToken().pipe(
Effect.catchAll(() => Effect.succeed(null))
)
return token === null
? request
: HttpClientRequest.setHeader(request, "Authorization", `Bearer ${token}`)
}),
),
)
}),
).pipe(/* ... provide necessary layers like FetchHttpClient, AuthServiceLive ... */)
...
import { AtomHttpApi } from '@effect-atom/atom-react'
import { HttpClient, HttpClientRequest } from '@effect/platform'
import { Effect, Layer } from 'effect'
// ... other app-specific imports like GroupXXXApi, AuthService
const GroupXXXApiLive = Layer.effect(
HttpClient.HttpClient,
Effect.gen(function* () {
const client = yield* HttpClient.HttpClient
const auth = yield* AuthService // Assuming you have an auth service
return client.pipe(
// This creates a new client that won't add tracing headers
HttpClient.withTracerPropagation(false),
// You can still chain other customizations, like adding auth tokens
HttpClient.mapRequestEffect(request =>
Effect.gen(function* () {
// ... your auth logic to get a token and add it to the request ...
const token = yield* auth.getAccessToken().pipe(
Effect.catchAll(() => Effect.succeed(null))
)
return token === null
? request
: HttpClientRequest.setHeader(request, "Authorization", `Bearer ${token}`)
}),
),
)
}),
).pipe(/* ... provide necessary layers like FetchHttpClient, AuthServiceLive ... */)
...