penambahan docker dan lain lain untuk penyesuaian docker

This commit is contained in:
Fanrouver
2026-05-19 09:57:46 +07:00
parent cb3310b44b
commit bc74b98cfd
23 changed files with 506 additions and 67 deletions
+2 -1
View File
@@ -67,7 +67,8 @@ export default defineEventHandler(async (event) => {
console.log('🎲 Generated state:', state.substring(0, 8) + '...')
const oauthDuration = (config.oauthStateDurationMinutes || 10) * 60; // Default to 10 minutes
const isSecure = process.env.NODE_ENV === 'production';
const isSecure = process.env.NODE_ENV === 'production' &&
event.node.req.headers['x-forwarded-proto'] === 'https';
// Store state in session cookie
// IMPORTANT: This cookie is ONLY for the login flow (CSRF protection).
+3 -1
View File
@@ -189,7 +189,9 @@ export default defineEventHandler(async (event) => {
if (primaryGroup) params.append('groups', primaryGroup);
// Backend API URL - adjust this to match your backend
const backendUrl = `http://10.10.123.140:8089/api/v1/permission?${params.toString()}`;
const config = useRuntimeConfig();
const apiBase = config.public.verificationApiBaseUrl || 'http://10.10.123.140:8089/api/v1';
const backendUrl = `${apiBase}/permission?${params.toString()}`;
try {
console.log(`📡 Fetching permissions from: ${backendUrl}`);
+37
View File
@@ -0,0 +1,37 @@
import { defineEventHandler, proxyRequest } from 'h3'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const targetBase = config.public.verificationApiBaseUrl || 'http://10.10.123.140:8089/api/v1'
// Extract path suffix after /klinik-api
const suffix = event.path.replace(/^\/klinik-api/, '')
const targetUrl = `${targetBase}${suffix}`
// Clone request headers and overwrite Host/Origin/Referer with backend-whitelisted values
const headers = { ...event.node.req.headers } as Record<string, string>
// Extract backend target host
try {
const urlObj = new URL(targetBase)
headers.host = urlObj.host
} catch (e) {
headers.host = '10.10.123.140:8089'
}
// Spoof the origin and referer to match the server's trusted/whitelisted client origin
headers.origin = 'http://10.10.150.175:3000'
headers.referer = 'http://10.10.150.175:3000/'
console.log(`[Proxy Klinik-API] Forwarding ${event.node.req.method} to: ${targetUrl}`)
console.log(`[Proxy Klinik-API] Headers - Host: ${headers.host}, Origin: ${headers.origin}`)
try {
return await proxyRequest(event, targetUrl, {
headers
})
} catch (error: any) {
console.error(`[Proxy Klinik-API] Error forwarding to ${targetUrl}:`, error)
throw error
}
})
+37
View File
@@ -0,0 +1,37 @@
import { defineEventHandler, proxyRequest } from 'h3'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const targetBase = config.public.externalApiBaseUrl || 'http://10.10.123.135:8084/api/v1'
// Extract path suffix after /stats-api
const suffix = event.path.replace(/^\/stats-api/, '')
const targetUrl = `${targetBase}${suffix}`
// Clone request headers and overwrite Host/Origin/Referer with backend-whitelisted values
const headers = { ...event.node.req.headers } as Record<string, string>
// Extract backend target host
try {
const urlObj = new URL(targetBase)
headers.host = urlObj.host
} catch (e) {
headers.host = '10.10.123.135:8084'
}
// Spoof the origin and referer to match the server's trusted/whitelisted client origin
headers.origin = 'http://10.10.150.175:3000'
headers.referer = 'http://10.10.150.175:3000/'
console.log(`[Proxy Stats-API] Forwarding ${event.node.req.method} to: ${targetUrl}`)
console.log(`[Proxy Stats-API] Headers - Host: ${headers.host}, Origin: ${headers.origin}`)
try {
return await proxyRequest(event, targetUrl, {
headers
})
} catch (error: any) {
console.error(`[Proxy Stats-API] Error forwarding to ${targetUrl}:`, error)
throw error
}
})
+37
View File
@@ -0,0 +1,37 @@
import { defineEventHandler, proxyRequest } from 'h3'
export default defineEventHandler(async (event) => {
const config = useRuntimeConfig()
const targetBase = config.public.externalApiBaseUrl || 'http://10.10.123.135:8084/api/v1'
// Extract path suffix after /visit-api
const suffix = event.path.replace(/^\/visit-api/, '')
const targetUrl = `${targetBase}${suffix}`
// Clone request headers and overwrite Host/Origin/Referer with backend-whitelisted values
const headers = { ...event.node.req.headers } as Record<string, string>
// Extract backend target host
try {
const urlObj = new URL(targetBase)
headers.host = urlObj.host
} catch (e) {
headers.host = '10.10.123.135:8084'
}
// Spoof the origin and referer to match the server's trusted/whitelisted client origin
headers.origin = 'http://10.10.150.175:3000'
headers.referer = 'http://10.10.150.175:3000/'
console.log(`[Proxy Visit-API] Forwarding ${event.node.req.method} to: ${targetUrl}`)
console.log(`[Proxy Visit-API] Headers - Host: ${headers.host}, Origin: ${headers.origin}`)
try {
return await proxyRequest(event, targetUrl, {
headers
})
} catch (error: any) {
console.error(`[Proxy Visit-API] Error forwarding to ${targetUrl}:`, error)
throw error
}
})