generated from lucien/actix-react-template
Add api proxy
This commit is contained in:
parent
2adacceac5
commit
e2261f829c
3 changed files with 43 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
import NavBar from '../components/NavBar';
|
||||||
|
import Footer from '../components/Footer';
|
||||||
|
|
||||||
interface Article {
|
interface Article {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -7,6 +9,7 @@ interface Article {
|
||||||
content: string;
|
content: string;
|
||||||
author: string;
|
author: string;
|
||||||
publishedAt: string;
|
publishedAt: string;
|
||||||
|
editedAt: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ArticlePage: React.FC = () => {
|
const ArticlePage: React.FC = () => {
|
||||||
|
@ -36,17 +39,38 @@ const ArticlePage: React.FC = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div style={{
|
||||||
<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages8.alphacoders.com%2F438%2F438396.jpg&f=1&nofb=1&ipt=14796576c139b58db62d2d2098392ef2fbaee77911040f7c0d98ab65a69c4644&ipo=images" alt="Article preview" style={{
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
minHeight: '100vh'
|
||||||
|
}}>
|
||||||
|
<NavBar/>
|
||||||
|
<div style={{
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
width: '100%',
|
color: 'var(--color-black)',
|
||||||
height: 'auto',
|
fontFamily: '"Haas Grot Text R Web", "Helvetica Neue", Helvetica, Arial, sans-serif',
|
||||||
marginBottom: '10px',
|
fontSize: '14px',
|
||||||
}} />
|
lineHeight: '20px',
|
||||||
<h1>{article.title}</h1>
|
padding: '1.25em',
|
||||||
<p>{article.content}</p>
|
paddingBottom: '1em',
|
||||||
<p>By {article.author}</p>
|
textAlign: 'left',
|
||||||
<p>Published on {new Date(article.publishedAt).toLocaleDateString()}</p>
|
maxWidth: '60rem',
|
||||||
|
margin: 'auto',
|
||||||
|
}}>
|
||||||
|
<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fimages8.alphacoders.com%2F438%2F438396.jpg&f=1&nofb=1&ipt=14796576c139b58db62d2d2098392ef2fbaee77911040f7c0d98ab65a69c4644&ipo=images" alt="Article preview" style={{
|
||||||
|
borderRadius: '8px',
|
||||||
|
width: '100%',
|
||||||
|
height: 'auto',
|
||||||
|
marginBottom: '10px',
|
||||||
|
}} />
|
||||||
|
<div>
|
||||||
|
<h1>{article.title}</h1>
|
||||||
|
<p>écrit par {article.author} le {new Date(article.publishedAt).toLocaleDateString()} (Dernière modification le : {new Date(article.editedAt || article.publishedAt).toLocaleDateString()})</p>
|
||||||
|
<hr/>
|
||||||
|
<p>{article.content}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Footer bgcolor='lightblue'/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@ export default function MainPage() {
|
||||||
txtbt1="Un"
|
txtbt1="Un"
|
||||||
txtbt2="Deux"
|
txtbt2="Deux"
|
||||||
image="url('/pictures/sea.gif')"/>
|
image="url('/pictures/sea.gif')"/>
|
||||||
<div style={{height:"30px"}} />
|
|
||||||
<ArticlesSection />
|
<ArticlesSection />
|
||||||
<Footer bgcolor="lightblue"/>
|
<Footer bgcolor="lightblue"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,4 +4,13 @@ import react from '@vitejs/plugin-react'
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:2486',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: path => path.replace(/^\/api/, '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue