From 2f91b14f75e28a559df823705b7367771e1e31e0 Mon Sep 17 00:00:00 2001 From: Marlene <57748216+marlenezw@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:20:06 +0000 Subject: [PATCH] adding changes for web to work. --- infra/ai.yaml | 2 +- src/web/Dockerfile | 8 +++----- src/web/nginx/nginx.conf | 7 ++++++- src/web/src/store/index.ts | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/infra/ai.yaml b/infra/ai.yaml index 78fda4bb..9dcfd956 100644 --- a/infra/ai.yaml +++ b/infra/ai.yaml @@ -24,4 +24,4 @@ deployments: version: "2024-07-18" sku: name: "Standard" - capacity: 8 + capacity: 10 diff --git a/src/web/Dockerfile b/src/web/Dockerfile index d9695cd4..a3994eee 100644 --- a/src/web/Dockerfile +++ b/src/web/Dockerfile @@ -20,9 +20,7 @@ WORKDIR /app COPY --from=ui /app/dist/* ./ COPY --from=ui /app/dist/assets/* ./assets/ -COPY ./nginx/nginx.conf /etc/nginx/conf.d/default.conf -COPY ./nginx/run_nginx.sh /bin/run_nginx.sh - EXPOSE 80 -RUN ["chmod", "+x", "/bin/run_nginx.sh"] -CMD ["/bin/run_nginx.sh"] \ No newline at end of file + +COPY ./nginx/nginx.conf /nginx.conf.template +CMD ["/bin/sh" , "-c" , "envsubst < /nginx.conf.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"] \ No newline at end of file diff --git a/src/web/nginx/nginx.conf b/src/web/nginx/nginx.conf index b722527f..e30afbd7 100644 --- a/src/web/nginx/nginx.conf +++ b/src/web/nginx/nginx.conf @@ -3,6 +3,11 @@ server { location / { root /app; index index.html index.htm; - try_files $uri $uri/ /index.html =404; + } + + location /api { + proxy_ssl_server_name on; + proxy_http_version 1.1; + proxy_pass '${API_ENDPOINT}'; } } \ No newline at end of file diff --git a/src/web/src/store/index.ts b/src/web/src/store/index.ts index 92003b8b..f0a946d6 100644 --- a/src/web/src/store/index.ts +++ b/src/web/src/store/index.ts @@ -57,11 +57,12 @@ export const startWritingTask = ( const url = `${ endpoint.endsWith("/") ? endpoint : endpoint + "/" - }api/article`; + }`; + console.log(url); const callApi = async () => { try { - const response = await fetch(url, configuration); + const response = await fetch("/api/article", configuration); const reader = response.body?.getReader(); if (!reader) return; @@ -96,4 +97,4 @@ export const startWritingTask = ( callApi(); -}; +}; \ No newline at end of file