Skip to content

Commit

Permalink
few changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishab87 committed Aug 1, 2024
1 parent a508052 commit c00dc8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions front-end-nextjs/src/app/api/proxy/route.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NextResponse } from 'next/server';

export async function POST(req) {
return await handleProxy(req);
}
Expand All @@ -6,8 +8,8 @@ async function handleProxy(req) {

const body = await req.json();
const {url} = body;
//use /backend/ instead of /backend-service/ for development
const backendUrl = `http://backend-service:8000/generate-qr/?${url}`;
//use /backend/ instead of /backend-service.default.svc.cluster.local:8000 for development
const backendUrl = `http://backend-service.default.svc.cluster.local:8000/generate-qr/?url=${url}`;

const response = await fetch(backendUrl , {
method: 'POST',
Expand All @@ -17,13 +19,14 @@ async function handleProxy(req) {
});

if (!response.ok) {
return {
return NextResponse.json({
status: response.status,
body: await response.text(),
};
} , {status: 500});
}

const data = await response.json();
return data.data.qr_code_url;
console.log(data);
return NextResponse.json({data: data.qr_code_url});

}
4 changes: 2 additions & 2 deletions front-end-nextjs/src/app/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export default function Home() {
}

const data = await response.json();
console.log(data);
setQrCodeUrl(data);
console.log(data);
setQrCodeUrl(data.data);
} catch (error) {
console.error('Error generating QR Code:', error);
}
Expand Down

0 comments on commit c00dc8f

Please sign in to comment.