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

feat(gui): proxy Admin API #296

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/actions/select-gateway-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
shell: bash
env:
DEFAULT_GATEWAY_IMAGE: |-
${{ format('{0}', inputs.enterprise) == 'true' && 'kong/kong-gateway-internal:nightly-ubuntu' || 'kong/kong:master-ubuntu' }}
${{ format('{0}', inputs.enterprise) == 'true' && 'kong/kong-gateway-internal:nightly-ubuntu' || 'kong/kong:pr-13647-ubuntu' }}
run: |
GATEWAY_IMAGE="${{ inputs.current-image }}"

Expand Down
13 changes: 5 additions & 8 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,15 @@ export const config = {
},

get ADMIN_API_URL() {
const ADMIN_API_URL = getConfig<string | null>('ADMIN_API_URL', null)
const ADMIN_API_URL = getConfig('ADMIN_API_URL', '')

if (ADMIN_API_URL) {
return /^(https?:)?\/\//.test(ADMIN_API_URL)
? ADMIN_API_URL
: `${window.location.protocol}//${ADMIN_API_URL}`
return /^(https?:)?\/\//.test(ADMIN_API_URL) ? ADMIN_API_URL : `${window.location.protocol}//${ADMIN_API_URL}`
}

const port = window.location.protocol.toLowerCase() === 'https:'
? config.ADMIN_API_SSL_PORT
: config.ADMIN_API_PORT
const baseUrl = `${window.location.protocol}//${window.location.hostname}:${window.location.port}`

return `${window.location.protocol}//${window.location.hostname}:${port}`
return `${baseUrl}${config.ADMIN_GUI_PATH === '/' ? '' : config.ADMIN_GUI_PATH}/gateway/api`
},

get ANONYMOUS_REPORTS() {
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default defineConfig({
server: {
proxy: {
'/kconfig.js': process.env.KONG_GUI_URL || 'http://127.0.0.1:8002',
'/gateway/api': {
target: process.env.KONG_GUI_API_URL || 'http://127.0.0.1:8001',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/gateway\/api/, ''),
},
},
port: 8080,
},
Expand Down
Loading