Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
marhaupe committed Oct 10, 2024
1 parent de13445 commit 939f1d3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ COPY packages/frontend/pnpm-lock.yaml .
RUN pnpm install --frozen-lockfile
COPY packages/frontend/ .
RUN pnpm build
RUN sed -i 's|<!--#echo var="configscript" -->|<script>window.config = {"backendURL": "https://uitail-demo.api.marhaupe.com"};</script>|' dist/index.html


FROM golang:1.23
WORKDIR /app
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/internal/static/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func (s *Static) Handler() iris.Handler {
return
}
config := struct {
Command string `json:"command"`
Port int `json:"port"`
Command string `json:"command"`
BackendURL string `json:"backendURL"`
}{
Command: s.Command,
Port: s.Port,
Command: s.Command,
BackendURL: fmt.Sprintf("http://localhost:%d", s.Port),
}
configJSON, err := json.Marshal(config)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function App() {
const logListRef = useRef<LogListRef>(null);

useEffect(() => {
const url = new URL(`http://localhost:${config.port}${config.routes.events}`);
const url = new URL(`${config.backendURL}${config.routes.events}`);
url.searchParams.set("stream", nanoid());
if (filterState.message) {
url.searchParams.set("filter", filterState.message);
Expand Down Expand Up @@ -61,7 +61,7 @@ export function App() {

async function handleClear() {
try {
const response = await fetch(`http://localhost:${config.port}${config.routes.clear}`, {
const response = await fetch(`${config.backendURL}${config.routes.clear}`, {
method: "POST",
});
if (response.ok) {
Expand All @@ -75,7 +75,7 @@ export function App() {

async function handleRestart() {
try {
const response = await fetch(`http://localhost:${config.port}${config.routes.restart}`, {
const response = await fetch(`${config.backendURL}${config.routes.restart}`, {
method: "POST",
});
if (response.ok) {
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare global {
interface Window {
config: {
port: number;
backendURL: string;
command: string;
};
}
Expand All @@ -14,7 +14,7 @@ export const config = {
clear: "/clear",
},
...(window.config || {
port: 8765,
backendURL: "http://localhost:8765",
command: "",
}),
};

0 comments on commit 939f1d3

Please sign in to comment.