Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/next-edge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export interface CreateApiHandlerOptions {
* https://playground.projects.oryapis.com
*/
apiBaseUrlOverride?: string

/**
* If set overrides the ui/welcome redirection.
*/
appRootPath?: string

/**
* Per default, this handler will strip the cookie domain from
Expand Down Expand Up @@ -135,11 +140,22 @@ export function createApiHandler(options: CreateApiHandlerOptions) {
const path = Array.isArray(paths) ? paths.join("/") : paths
const url = `${baseUrl}/${path}?${search.toString()}`

if (path === "ui/welcome") {
if (path.startsWith("ui/welcome")) {
let pathArray = path.split("/")
let subPath = ''
if(pathArray.length > 2){
pathArray.splice(0,2)
subPath = '/' + pathArray.join('/')
}
let redirectUrl = "../../../" + subPath
if (appRootPath){
redirectUrl = appRootPath + subPath
}

// A special for redirecting to the home page
// if we were being redirected to the hosted UI
// welcome page.
res.redirect(303, "../../../")
res.redirect(303, redirectUrl )
return
}

Expand Down