Spaces:
Paused
Paused
File size: 872 Bytes
4e75170 0604cf4 4e75170 0604cf4 4e75170 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | const path = require('path')
function trimTrailingSlash(value) {
return value.replace(/\/+$/, '')
}
function resolveApiBaseUrl() {
const explicitApiUrl = process.env.NEXT_PUBLIC_API_URL?.trim()
if (explicitApiUrl) {
return trimTrailingSlash(explicitApiUrl)
}
const hfSpaceId = (process.env.NEXT_PUBLIC_HF_SPACE_ID ?? 'akagtag/deepdetection').trim()
const [owner, space] = hfSpaceId.split('/')
if (owner && space) {
return `https://${owner}-${space}.hf.space`
}
return 'http://localhost:8000'
}
const API_BASE_URL = resolveApiBaseUrl()
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
outputFileTracingRoot: path.join(__dirname),
async rewrites() {
return [
{
source: '/api/:path*',
destination: `${API_BASE_URL}/:path*`,
},
]
},
}
module.exports = nextConfig
|