diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00b633e..b1cbc4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,8 +84,8 @@ jobs: build-docker-image-front: runs-on: ubuntu-latest env: - VITE_API_BASE: http://backend:8080/itmo-trip/api/v1 - VITE_API_TARGET: http://backend:8080 + VITE_API_BASE: http://trips.itmo.tw1.su:8080/itmo-trip/api/v1 + VITE_API_TARGET: http://trips.itmo.tw1.su:8080 permissions: contents: read packages: write diff --git a/frontend/.env b/frontend/.env index f7c604d..cd5a025 100644 --- a/frontend/.env +++ b/frontend/.env @@ -1,2 +1,2 @@ -VITE_API_BASE=http://localhost:8080/itmo-trip/api/v1 -VITE_API_TARGET=http://localhost:8080 \ No newline at end of file +VITE_API_BASE=http://trips.itmo.tw1.su:8080/itmo-trip/api/v1 +VITE_API_TARGET=http://trips.itmo.tw1.su:8080 \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile index ce731ea..68b1cfe 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -4,16 +4,17 @@ WORKDIR /app COPY package*.json ./ -RUN rm -rf node_modules package-lock.json && npm install +RUN rm -rf node_modules package-lock.json && \ + npm install --force COPY . . -FROM node:22-bullseye +RUN npm run build -WORKDIR /app +FROM nginx:alpine -COPY --from=builder /app /app +COPY --from=builder /app/dist /usr/share/nginx/html -EXPOSE 5177 +EXPOSE 80 -CMD ["npm", "run", "dev"] +CMD ["nginx", "-g", "daemon off;"] diff --git a/frontend/src/api/CustomAuthService.ts b/frontend/src/api/CustomAuthService.ts index 7b2ab7c..b1b1688 100644 --- a/frontend/src/api/CustomAuthService.ts +++ b/frontend/src/api/CustomAuthService.ts @@ -1,5 +1,5 @@ import AuthUtils from "../services/AuthUtils.ts"; -import {API_BASE, API_BASE_AVOID_CORS} from "./OpenAPI.custom.ts"; +import {API_BASE} from "./OpenAPI.custom.ts"; export async function login(username: string, password: string): Promise { try { diff --git a/frontend/src/api/OpenAPI.custom.ts b/frontend/src/api/OpenAPI.custom.ts index 1143759..ed5fa6f 100644 --- a/frontend/src/api/OpenAPI.custom.ts +++ b/frontend/src/api/OpenAPI.custom.ts @@ -3,7 +3,6 @@ import type { ApiRequestOptions } from './generated/core/ApiRequestOptions'; export const API_BASE = import.meta.env.VITE_API_BASE; -export const API_BASE_AVOID_CORS = "/itmo-trip" // смотреть в vite.config.ts type Resolver = (options: ApiRequestOptions) => Promise; type Headers = Record; @@ -21,7 +20,7 @@ export type OpenAPIConfig = { }; export const OpenAPI: OpenAPIConfig = { - BASE: API_BASE_AVOID_CORS, + BASE: API_BASE, VERSION: '1.0.0', WITH_CREDENTIALS: false, CREDENTIALS: 'include', diff --git a/frontend/src/components/AuthForm.tsx b/frontend/src/components/AuthForm.tsx index c742e99..ec34dde 100644 --- a/frontend/src/components/AuthForm.tsx +++ b/frontend/src/components/AuthForm.tsx @@ -6,7 +6,7 @@ import { Typography, } from "@mui/material"; import { login, getUserProfile } from "../api/CustomAuthService.ts"; -import {API_BASE_AVOID_CORS} from "../api/OpenAPI.custom.ts"; +import {API_BASE} from "../api/OpenAPI.custom.ts"; interface AuthFormProps { onSuccess: () => void; @@ -66,7 +66,7 @@ export function AuthForm({ onSuccess, onProfileComplete }: AuthFormProps) { try { // PATCH user with BIO and SOCIAL_NETWORK_USER_NAME - const res = await fetch(`${API_BASE_AVOID_CORS}/api/v1/users/${userUuid}`, { + const res = await fetch(`${API_BASE}/users/${userUuid}`, { method: "PATCH", headers: { "Content-Type": "application/json", diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 1bf3415..b8501e9 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,7 +1,7 @@ -import { defineConfig, loadEnv } from 'vite' +import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' -export default defineConfig(({ mode }) => { +export default defineConfig(() => { const target = process.env.VITE_API_TARGET console.log(target) @@ -10,7 +10,7 @@ export default defineConfig(({ mode }) => { plugins: [react()], server: { host: '0.0.0.0', - allowedHosts: true, + allowedHosts: true as true, port: 5177, }, }; diff --git a/local-env/docker-compose.yml b/local-env/docker-compose.yml index 7790f4d..25f9f6f 100644 --- a/local-env/docker-compose.yml +++ b/local-env/docker-compose.yml @@ -49,15 +49,17 @@ services: build: context: .././frontend dockerfile: Dockerfile +# platforms: +# - "linux/amd64" args: - - VITE_API_BASE=${VITE_API_BASE} - - VITE_API_TARGET=${VITE_API_TARGET} + - VITE_API_BASE=http://trips.itmo.tw1.su:8080/itmo-trip/api/v1 + - VITE_API_TARGET=http://trips.itmo.tw1.su:8080 container_name: itmo-trip-frontend environment: VITE_API_BASE: ${VITE_API_BASE} VITE_API_TARGET: ${VITE_API_TARGET} ports: - - "5177:5177" + - "5177:80" depends_on: backend: condition: service_healthy diff --git a/src/main/kotlin/ru/itmo/dws/itmotrip/security/SecurityConfiguration.kt b/src/main/kotlin/ru/itmo/dws/itmotrip/security/SecurityConfiguration.kt index 28d41ea..ab78c34 100644 --- a/src/main/kotlin/ru/itmo/dws/itmotrip/security/SecurityConfiguration.kt +++ b/src/main/kotlin/ru/itmo/dws/itmotrip/security/SecurityConfiguration.kt @@ -23,6 +23,7 @@ class SecurityConfiguration { it.requestMatchers("/readyz").permitAll() it.requestMatchers("/api/v1/auth/*").permitAll() it.requestMatchers(HttpMethod.GET).permitAll() + it.requestMatchers(HttpMethod.OPTIONS).permitAll() it.anyRequest().authenticated() }