Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customization option for app path #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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