Skip to content

Commit

Permalink
Merge pull request #315 from marlenezw/local_dev
Browse files Browse the repository at this point in the history
fixing local url enpoint.
  • Loading branch information
marlenezw authored Jan 27, 2025
2 parents 438371e + 9804fe8 commit 4a4b033
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/web/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { endpoint } from "../constants";
import { githubDevSubsPort } from "../utils/ghutils";
export interface IMessage {
type: "message" | "researcher" | "marketing" | "writer" | "editor" | "error" | "partial";
message: string;
Expand Down Expand Up @@ -55,14 +55,24 @@ export const startWritingTask = (
}),
};

const hostname = window.location.hostname;
const apiPort = 8000;

const endpoint =
(hostname === 'localhost' || hostname === '127.0.0.1')
? `http://localhost:${apiPort}`
: hostname.endsWith('github.dev')
? `${githubDevSubsPort(hostname, apiPort)}/`
: "";


const url = `${
endpoint.endsWith("/") ? endpoint : endpoint + "/"
}`;
console.log(url);
}api/article`;

const callApi = async () => {
try {
const response = await fetch("/api/article", configuration);
const response = await fetch(url, configuration);
const reader = response.body?.getReader();
if (!reader) return;

Expand All @@ -73,7 +83,7 @@ export const startWritingTask = (
for (let part of parts) {
part = part.trim();
if (!part || part.length === 0) continue;
console.log(part);
// console.log(part);
const message = JSON.parse(part) as IMessage;
addMessage(message);
if (message.type === "writer") {
Expand Down

0 comments on commit 4a4b033

Please sign in to comment.