Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_BASE=http://localhost:8080/itmo-trip/api/v1
VITE_API_TARGET=http://localhost:8080
VITE_API_BASE=http://trips.itmo.tw1.su:8080/itmo-trip/api/v1
VITE_API_TARGET=http://trips.itmo.tw1.su:8080
13 changes: 7 additions & 6 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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;"]
2 changes: 1 addition & 1 deletion frontend/src/api/CustomAuthService.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
try {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/api/OpenAPI.custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = (options: ApiRequestOptions) => Promise<T>;
type Headers = Record<string, string>;
Expand All @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -10,7 +10,7 @@ export default defineConfig(({ mode }) => {
plugins: [react()],
server: {
host: '0.0.0.0',
allowedHosts: true,
allowedHosts: true as true,
port: 5177,
},
};
Expand Down
8 changes: 5 additions & 3 deletions local-env/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down