When you request a check transaction to Bakong API from outside Cambodia, and you get this response:

What to do? Move the application to the Cambodia server? I don’t know!
But I have an idea! 🤔 Why don’t we create a proxy and then route the request check transaction to the hosted server in Cambodia?
Let’s set up
bun create hono@latest khqr-proxy cd khqr-proxy bun install
Open: src/index.ts
import { Hono } from "hono"; import { proxy } from "hono/proxy"; const app = new Hono(); // You can change the path based on your needs app.all("*", async (c) => { const path = c.req.path; // if you changed path, replace this: c.req.path.replace('/proxy', ''); const query = c.req.query(); const baseUrl = "https://api-bakong.nbc.gov.kh"; const url = `${baseUrl}${path}?${new URLSearchParams(query)}`; const headers = new Headers(c.req.header()); headers.set("host", "api-bakong.nbc.gov.kh"); const res = await proxy(url, { method: c.req.method, headers, raw: c.req.raw, }); return res; }); export default app;
Run local development:
bun run dev
Deploy
Your server needs to have Bun installed or Docker. I recommend using Docker deployment as an easy way.
If you don’t have Docker please check here: https://docs.docker.com/engine/install/ubuntu/
Dockerfile
# syntax = docker/dockerfile:1 # Adjust BUN_VERSION as desired ARG BUN_VERSION=1.2.20 FROM oven/bun:${BUN_VERSION}-slim AS base # Bun app lives here WORKDIR /app # Set production environment ENV NODE_ENV="production" # Throw-away build stage to reduce size of final image FROM base AS build # Install node modules COPY bun.lock package.json ./ RUN bun install --ci # Copy application code COPY . . # Final stage for app image FROM base ARG PORT=3000 ENV PORT=${PORT} # Copy built application COPY /app /app # Start the server by default; this can be overwritten at runtime EXPOSE ${PORT} CMD [ "bun", "start" ]
docker-compose.yml
services: app: build: context: . dockerfile: Dockerfile ports: - "3000:3000" restart: unless-stopped
Start:
docker compose up -d
Noted: if you don’t want to use Hono JS, you can use anything you want.
check repo: Here