Skip to content

Commit

Permalink
feat: support additional headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 8, 2025
1 parent 92ad6a0 commit 9b66cad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/next-edge-app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export function createApiHandler(options: CreateApiHandlerOptions) {
requestHeaders.set("Ory-Base-URL-Rewrite", "false")
requestHeaders.set("Ory-No-Custom-Domain-Redirect", "true")

for (const [key, value] of options.additionalHeaders) {
requestHeaders.set(key, value)
}

try {
const response = await fetch(url, {
method: request.method,
Expand Down
4 changes: 4 additions & 0 deletions src/next-edge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export function createApiHandler(options: CreateApiHandlerOptions) {
headers.set("Ory-Base-URL-Rewrite", "false")
headers.set("Ory-No-Custom-Domain-Redirect", "true")

for (const [key, value] of options.additionalHeaders) {
headers.set(key, value)
}

const response = await fetch(url, {
method: req.method,
headers,
Expand Down
7 changes: 6 additions & 1 deletion src/type/create-api-handler-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ export interface CreateApiHandlerOptions {
*/
fallbackToPlayground?: boolean

/*
/**
* Per default headers are filtered to forward only a fixed list.
*
* If you need to forward additional headers you can use this setting to define them.
*/
forwardAdditionalHeaders?: string[]

/**
* Define additional headers to pass to the API.
*/
additionalHeaders?: Headers
}

0 comments on commit 9b66cad

Please sign in to comment.