mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2025-12-12 18:28:50 +00:00
Update HttpClient to include proxy operations in API key usage logic and enhance request header logging for proxy paths.
This commit is contained in:
parent
23a742e5d4
commit
8c9a900e88
@ -54,13 +54,14 @@ export class HttpClient {
|
|||||||
private getAuthHeaders(path: string): Record<string, string> {
|
private getAuthHeaders(path: string): Record<string, string> {
|
||||||
const headers: Record<string, string> = {};
|
const headers: Record<string, string> = {};
|
||||||
|
|
||||||
// For database and pubsub operations, ONLY use API key to avoid JWT user context
|
// For database, pubsub, and proxy operations, ONLY use API key to avoid JWT user context
|
||||||
// interfering with namespace-level authorization
|
// interfering with namespace-level authorization
|
||||||
const isDbOperation = path.includes("/v1/rqlite/");
|
const isDbOperation = path.includes("/v1/rqlite/");
|
||||||
const isPubSubOperation = path.includes("/v1/pubsub/");
|
const isPubSubOperation = path.includes("/v1/pubsub/");
|
||||||
|
const isProxyOperation = path.includes("/v1/proxy/");
|
||||||
|
|
||||||
if (isDbOperation || isPubSubOperation) {
|
if (isDbOperation || isPubSubOperation || isProxyOperation) {
|
||||||
// For database/pubsub operations: use only API key (preferred for namespace operations)
|
// For database/pubsub/proxy operations: use only API key (preferred for namespace operations)
|
||||||
if (this.apiKey) {
|
if (this.apiKey) {
|
||||||
headers["X-API-Key"] = this.apiKey;
|
headers["X-API-Key"] = this.apiKey;
|
||||||
} else if (this.jwt) {
|
} else if (this.jwt) {
|
||||||
@ -116,7 +117,8 @@ export class HttpClient {
|
|||||||
(path.includes("/db/") ||
|
(path.includes("/db/") ||
|
||||||
path.includes("/query") ||
|
path.includes("/query") ||
|
||||||
path.includes("/auth/") ||
|
path.includes("/auth/") ||
|
||||||
path.includes("/pubsub/"))
|
path.includes("/pubsub/") ||
|
||||||
|
path.includes("/proxy/"))
|
||||||
) {
|
) {
|
||||||
console.log("[HttpClient] Request headers for", path, {
|
console.log("[HttpClient] Request headers for", path, {
|
||||||
hasAuth: !!headers["Authorization"],
|
hasAuth: !!headers["Authorization"],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user