File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1515 * limitations under the License.
1616 *
1717 */
18-
1918{
2019 "name" : " Go" ,
2120 "dockerComposeFile" : " docker-compose.yml" ,
3635 4000 ,
3736 8080
3837 ],
38+ "containerEnv" : {
39+ "VITE_GRAFANA_URL" : " http://grafana:3000" ,
40+ "VITE_GRAFANA_CHANGE_ORIGIN" : " false"
41+ },
3942 "postCreateCommand" : " npm install commitizen -g" ,
4043 "customizations" : {
4144 "vscode" : {
4548 }
4649 },
4750 "remoteUser" : " root"
48- }
51+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ import { defineConfig } from 'vite';
2121import react from '@vitejs/plugin-react' ;
2222import svgr from 'vite-plugin-svgr' ;
2323
24+ // Allow Grafana access from the dev server when using Dev Container
25+ const grafanaOrigin = process . env . VITE_GRAFANA_URL || 'http://localhost:3002' ;
26+ const grafanaChangeOrigin = envBool ( 'VITE_GRAFANA_CHANGE_ORIGIN' , true ) ;
27+
2428// https://vitejs.dev/config/
2529export default defineConfig ( {
2630 plugins : [ react ( ) , svgr ( ) ] ,
@@ -36,8 +40,9 @@ export default defineConfig({
3640 rewrite : ( path ) => path . replace ( / ^ \/ a p i \/ / , '' ) ,
3741 } ,
3842 '/grafana' : {
39- target : 'http://localhost:3002/' ,
40- changeOrigin : true ,
43+ target : grafanaOrigin ,
44+ changeOrigin : grafanaChangeOrigin ,
45+ ws : true // Proxying websockets to allow features like query auto-complete
4146 } ,
4247 } ,
4348 } ,
@@ -48,3 +53,9 @@ export default defineConfig({
4853 } ,
4954 } ,
5055} ) ;
56+
57+ function envBool ( name : string , defaultValue = false ) : boolean {
58+ const v = process . env [ name ] ;
59+ if ( v == null ) return defaultValue ;
60+ return / ^ ( 1 | t r u e | y e s | o n ) $ / i. test ( v ) ;
61+ }
You can’t perform that action at this time.
0 commit comments