TTs whisper
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig()
|
||||
const direction = getRouterParam(event, 'direction')
|
||||
|
||||
if (direction !== 'forward' && direction !== 'backwards') {
|
||||
@@ -9,7 +8,10 @@ export default defineEventHandler(async (event) => {
|
||||
})
|
||||
}
|
||||
|
||||
return await $fetch(`${config.quibotBaseUrl}/motor/step/${direction}`, {
|
||||
const baseUrl = getPiBaseUrl(event)
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
return await $fetch(`${baseUrl}/motor/step/${direction}`, {
|
||||
method: 'POST',
|
||||
query: {
|
||||
token: config.quibotToken,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
export default defineEventHandler(async () => {
|
||||
export default defineEventHandler(async (event) => {
|
||||
const baseUrl = getPiBaseUrl(event)
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
return await $fetch(`${config.quibotBaseUrl}/motor/stop`, {
|
||||
return await $fetch(`${baseUrl}/motor/stop`, {
|
||||
method: 'POST',
|
||||
query: {
|
||||
token: config.quibotToken,
|
||||
|
||||
10
quibot-web/server/plugins/settings.ts
Normal file
10
quibot-web/server/plugins/settings.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export default defineNitroPlugin((nitroApp) => {
|
||||
const base = useRuntimeConfig().quibotBaseUrl
|
||||
nitroApp.hooks.hook('request', (event) => {
|
||||
const url = getCookie(event, 'quibot-pi-url')
|
||||
if (url && url !== decodeURIComponent(base)) {
|
||||
// Override the base URL for this request
|
||||
(event.context as any).__piBaseUrl = url
|
||||
}
|
||||
})
|
||||
})
|
||||
9
quibot-web/server/utils/pi-url.ts
Normal file
9
quibot-web/server/utils/pi-url.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { getCookie } from 'h3'
|
||||
|
||||
export function getPiBaseUrl(event: any): string {
|
||||
const cookieUrl = getCookie(event, 'quibot-pi-url')
|
||||
if (cookieUrl) return decodeURIComponent(cookieUrl)
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
return config.quibotBaseUrl
|
||||
}
|
||||
Reference in New Issue
Block a user