From e2261f829ccb9770105e433ee4d93544cdc31dba Mon Sep 17 00:00:00 2001 From: = Date: Fri, 6 Dec 2024 02:50:16 +0100 Subject: [PATCH] Add api proxy --- front/src/pages/ArticlePage.tsx | 44 +++++++++++++++++++++++++-------- front/src/pages/MainPage.tsx | 1 - front/vite.config.ts | 9 +++++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/front/src/pages/ArticlePage.tsx b/front/src/pages/ArticlePage.tsx index b3d99ad..3ab05f8 100644 --- a/front/src/pages/ArticlePage.tsx +++ b/front/src/pages/ArticlePage.tsx @@ -1,5 +1,7 @@ import React, { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; +import NavBar from '../components/NavBar'; +import Footer from '../components/Footer'; interface Article { id: string; @@ -7,6 +9,7 @@ interface Article { content: string; author: string; publishedAt: string; + editedAt: string; } const ArticlePage: React.FC = () => { @@ -36,17 +39,38 @@ const ArticlePage: React.FC = () => { } return ( -
- Article preview + +
-

{article.title}

-

{article.content}

-

By {article.author}

-

Published on {new Date(article.publishedAt).toLocaleDateString()}

+ color: 'var(--color-black)', + fontFamily: '"Haas Grot Text R Web", "Helvetica Neue", Helvetica, Arial, sans-serif', + fontSize: '14px', + lineHeight: '20px', + padding: '1.25em', + paddingBottom: '1em', + textAlign: 'left', + maxWidth: '60rem', + margin: 'auto', + }}> + Article preview +
+

{article.title}

+

écrit par {article.author} le {new Date(article.publishedAt).toLocaleDateString()} (Dernière modification le : {new Date(article.editedAt || article.publishedAt).toLocaleDateString()})

+
+

{article.content}

+
+
+
); }; diff --git a/front/src/pages/MainPage.tsx b/front/src/pages/MainPage.tsx index d01d11c..a64aeef 100644 --- a/front/src/pages/MainPage.tsx +++ b/front/src/pages/MainPage.tsx @@ -11,7 +11,6 @@ export default function MainPage() { txtbt1="Un" txtbt2="Deux" image="url('/pictures/sea.gif')"/> -
diff --git a/front/vite.config.ts b/front/vite.config.ts index 8b0f57b..9e06ec4 100644 --- a/front/vite.config.ts +++ b/front/vite.config.ts @@ -4,4 +4,13 @@ import react from '@vitejs/plugin-react' // https://vite.dev/config/ export default defineConfig({ plugins: [react()], + server: { + proxy: { + '/api': { + target: 'http://localhost:2486', + changeOrigin: true, + rewrite: path => path.replace(/^\/api/, '') + } + } + } })