Skip to main content

Nuxt.js Integration

Use server routes (server/api/*) to call KoreShield safely.

Environment

KORESHIELD_BASE_URL=http://localhost:8000
KORESHIELD_JWT=<jwt-token>

Server Route Example

// server/api/chat.post.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event)

const response = await fetch(`${process.env.KORESHIELD_BASE_URL}/v1/chat/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.KORESHIELD_JWT}`,
},
body: JSON.stringify({
model: 'deepseek-chat',
messages: body.messages,
}),
})

return await response.json()
})

RAG Scan Route

// server/api/rag-scan.post.ts
export default defineEventHandler(async (event) => {
const body = await readBody(event)

const response = await fetch(`${process.env.KORESHIELD_BASE_URL}/v1/rag/scan`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.KORESHIELD_JWT}`,
},
body: JSON.stringify(body),
})

return await response.json()
})