Skip to content

Commit 2d4e9b8

Browse files
committed
fix: use service hostname for Grafana proxy
Use http://grafana:3000 (service discovery) instead of localhost:3000. This works in both: - Local dev: docker-compose service name - Railway: service-to-service networking
1 parent a433bca commit 2d4e9b8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/routes/grafana.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
22
import httpProxy from '@fastify/http-proxy';
33

44
const grafanaRoutes: FastifyPluginAsyncTypebox = async (fastify) => {
5-
// Proxy all /grafana requests to local Grafana instance
5+
// Proxy all /grafana requests to Grafana service
6+
// In Railway: add Grafana as a separate service, it will be available at http://grafana:3000
7+
// In local dev: docker-compose provides grafana service at http://grafana:3000
8+
const grafanaUrl = process.env.GRAFANA_URL || 'http://grafana:3000';
9+
610
await fastify.register(httpProxy, {
7-
upstream: 'http://localhost:3000',
11+
upstream: grafanaUrl,
812
prefix: '/grafana',
913
rewritePrefix: '/',
1014
http2: false,

0 commit comments

Comments
 (0)