hasurafix
This commit is contained in:
@@ -10,6 +10,12 @@
|
|||||||
status = 200
|
status = 200
|
||||||
force = true
|
force = true
|
||||||
|
|
||||||
|
[[redirects]]
|
||||||
|
from = "/v1/*"
|
||||||
|
to = "https://api.workolik.com/v1/:splat"
|
||||||
|
status = 200
|
||||||
|
force = true
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/*"
|
from = "/*"
|
||||||
to = "/index.html"
|
to = "/index.html"
|
||||||
|
|||||||
@@ -29,6 +29,18 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Proxy GraphQL v1 queries (e.g. /v1/graphql) to legacy backend
|
||||||
|
location /v1/ {
|
||||||
|
proxy_pass https://api.workolik.com/v1/;
|
||||||
|
proxy_set_header Host api.workolik.com;
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
|
||||||
|
# Optional: forward client IP
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_addrs;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
# Serve the React application
|
# Serve the React application
|
||||||
location / {
|
location / {
|
||||||
root /path/to/your/dist;
|
root /path/to/your/dist;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import 'dotenv/config'
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||||
const PORT = Number(process.env.PORT) || 3000
|
const PORT = Number(process.env.PORT) || 3000
|
||||||
const SECRET = (process.env.HASURA_ADMIN_SECRET || '').trim()
|
const SECRET = (process.env.HASURA_ADMIN_SECRET || 'nearle-admin-secret').trim()
|
||||||
const TARGET_LEGACY = 'https://api.workolik.com'
|
const TARGET_LEGACY = 'https://api.workolik.com'
|
||||||
const TARGET_REST = 'https://jupiter.nearle.app'
|
const TARGET_REST = 'https://jupiter.nearle.app'
|
||||||
|
|
||||||
@@ -57,6 +57,12 @@ app.use('/live', createProxyMiddleware({
|
|||||||
pathRewrite: (p) => '/live' + p
|
pathRewrite: (p) => '/live' + p
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
app.use('/v1', createProxyMiddleware({
|
||||||
|
...commonProxyOptions,
|
||||||
|
target: TARGET_LEGACY,
|
||||||
|
pathRewrite: (p) => '/v1' + p
|
||||||
|
}))
|
||||||
|
|
||||||
// Built React app
|
// Built React app
|
||||||
const distDir = path.join(__dirname, 'dist')
|
const distDir = path.join(__dirname, 'dist')
|
||||||
app.use(express.static(distDir))
|
app.use(express.static(distDir))
|
||||||
@@ -68,5 +74,6 @@ app.listen(PORT, () => {
|
|||||||
console.log(`[xpress-docs] listening on http://localhost:${PORT}`)
|
console.log(`[xpress-docs] listening on http://localhost:${PORT}`)
|
||||||
console.log(`[xpress-docs] proxying /api/* -> ${TARGET_LEGACY}/api/*`)
|
console.log(`[xpress-docs] proxying /api/* -> ${TARGET_LEGACY}/api/*`)
|
||||||
console.log(`[xpress-docs] proxying /live/* -> ${TARGET_REST}/live/*`)
|
console.log(`[xpress-docs] proxying /live/* -> ${TARGET_REST}/live/*`)
|
||||||
|
console.log(`[xpress-docs] proxying /v1/* -> ${TARGET_LEGACY}/v1/*`)
|
||||||
console.log(`[xpress-docs] admin secret: ${SECRET ? 'loaded' : 'NOT SET'}`)
|
console.log(`[xpress-docs] admin secret: ${SECRET ? 'loaded' : 'NOT SET'}`)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
"source": "/api/:path*",
|
"source": "/api/:path*",
|
||||||
"destination": "https://api.workolik.com/api/:path*"
|
"destination": "https://api.workolik.com/api/:path*"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"source": "/v1/:path*",
|
||||||
|
"destination": "https://api.workolik.com/v1/:path*"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"source": "/(.*)",
|
"source": "/(.*)",
|
||||||
"destination": "/index.html"
|
"destination": "/index.html"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import react from '@vitejs/plugin-react'
|
|||||||
// server-side so the secret never reaches the browser.
|
// server-side so the secret never reaches the browser.
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(({ mode }) => {
|
||||||
const env = loadEnv(mode, process.cwd(), '')
|
const env = loadEnv(mode, process.cwd(), '')
|
||||||
const secret = (env.HASURA_ADMIN_SECRET || '').trim()
|
const secret = (env.HASURA_ADMIN_SECRET || 'nearle-admin-secret').trim()
|
||||||
|
|
||||||
if (!secret) {
|
if (!secret) {
|
||||||
console.warn('[xpress-docs] HASURA_ADMIN_SECRET is not set in .env.local; proxied requests will hit the API without auth.')
|
console.warn('[xpress-docs] HASURA_ADMIN_SECRET is not set in .env.local; proxied requests will hit the API without auth.')
|
||||||
@@ -22,6 +22,16 @@ export default defineConfig(({ mode }) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'/v1': {
|
||||||
|
target: 'https://api.workolik.com',
|
||||||
|
changeOrigin: true,
|
||||||
|
secure: true,
|
||||||
|
configure: (proxy) => {
|
||||||
|
proxy.on('proxyReq', (proxyReq) => {
|
||||||
|
if (secret) proxyReq.setHeader('x-hasura-admin-secret', secret)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
'/live': {
|
'/live': {
|
||||||
target: 'https://jupiter.nearle.app',
|
target: 'https://jupiter.nearle.app',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user