Skip to content
Snippets Groups Projects
Commit 09a627c6 authored by Guilhem CARRON's avatar Guilhem CARRON
Browse files

Merge branch 'test-no-baseurl' of...

Merge branch 'test-no-baseurl' of https://forge.grandlyon.com/web-et-numerique/llle_project/backoffice-client into local-conf
parents 2aa887fb ecd88441
No related branches found
No related tags found
2 merge requests!8local- conf,!7feat: add front office
...@@ -23,4 +23,7 @@ server { ...@@ -23,4 +23,7 @@ server {
location /Logout { location /Logout {
proxy_pass https://backend:1443/Logout; proxy_pass https://backend:1443/Logout;
} }
location /swagger {
proxy_pass https://backend:1443/swagger;
}
} }
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<base href="%PUBLIC_URL%/">
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
......
...@@ -10,7 +10,7 @@ function App() { ...@@ -10,7 +10,7 @@ function App() {
const { user, setUser, isLoading } = useFindUser() const { user, setUser, isLoading } = useFindUser()
return ( return (
<BrowserRouter basename={process.env.PUBLIC_URL}> <BrowserRouter>
<UserContext.Provider value={{ user, setUser, isLoading }}> <UserContext.Provider value={{ user, setUser, isLoading }}>
<Layout> <Layout>
<Routes /> <Routes />
......
...@@ -16,9 +16,7 @@ export const useAuth = (): Auth => { ...@@ -16,9 +16,7 @@ export const useAuth = (): Auth => {
//login user //login user
const loginUser = async (): Promise<void> => { const loginUser = async (): Promise<void> => {
try { try {
await axios.get(`${process.env.PUBLIC_URL}OAuth2Login`, { window.location.href="/OAuth2Login"
withCredentials: true,
})
await setUserContext() await setUserContext()
} catch (e) { } catch (e) {
setError(e) setError(e)
...@@ -28,7 +26,7 @@ export const useAuth = (): Auth => { ...@@ -28,7 +26,7 @@ export const useAuth = (): Auth => {
const logoutUser = async (): Promise<void> => { const logoutUser = async (): Promise<void> => {
try { try {
if (setUser) setUser(null) if (setUser) setUser(null)
await axios.get(`${process.env.PUBLIC_URL}Logout`) window.location.href="/Logout"
} catch (e) { } catch (e) {
setError(e) setError(e)
} }
...@@ -37,12 +35,7 @@ export const useAuth = (): Auth => { ...@@ -37,12 +35,7 @@ export const useAuth = (): Auth => {
//set user in context and push them home //set user in context and push them home
const setUserContext = async (): Promise<void> => { const setUserContext = async (): Promise<void> => {
try { try {
const { data } = await axios.get( const { data } = await axios.get(`/api/common/WhoAmI`)
`${process.env.PUBLIC_URL}api/common/WhoAmI`,
{
withCredentials: true,
}
)
if (data && setUser) { if (data && setUser) {
setUser(data) setUser(data)
history.push('/editing') history.push('/editing')
......
...@@ -8,9 +8,7 @@ const useFindUser = () => { ...@@ -8,9 +8,7 @@ const useFindUser = () => {
useEffect(() => { useEffect(() => {
async function findUser() { async function findUser() {
const { data } = await axios.get( const { data } = await axios.get(`/api/common/WhoAmI`)
`${process.env.PUBLIC_URL}api/common/WhoAmI`
)
if (data) { if (data) {
setUser(data) setUser(data)
setLoading(false) setLoading(false)
......
...@@ -3,10 +3,7 @@ import { IMonthlyNews } from '../models/monthlyNews.model' ...@@ -3,10 +3,7 @@ import { IMonthlyNews } from '../models/monthlyNews.model'
import { IPoll } from '../models/poll.model' import { IPoll } from '../models/poll.model'
import { toast } from 'react-toastify' import { toast } from 'react-toastify'
export class MonthlyNewsService { export class MonthlyNewsService {
private readonly _apiUrl: string
constructor() {
this._apiUrl = 'https://localhost:443/'
}
/** /**
* Creates a quotation and header for selected month * Creates a quotation and header for selected month
* @param date * @param date
...@@ -21,7 +18,7 @@ export class MonthlyNewsService { ...@@ -21,7 +18,7 @@ export class MonthlyNewsService {
): Promise<void> => { ): Promise<void> => {
try { try {
await axios.put( await axios.put(
`${process.env.PUBLIC_URL}/api/admin/monthlyNews`, `/api/admin/monthlyNews`,
{ {
month: date.getMonth(), month: date.getMonth(),
year: date.getFullYear(), year: date.getFullYear(),
...@@ -51,7 +48,7 @@ export class MonthlyNewsService { ...@@ -51,7 +48,7 @@ export class MonthlyNewsService {
): Promise<IMonthlyNews | null> => { ): Promise<IMonthlyNews | null> => {
try { try {
const { data } = await axios.get( const { data } = await axios.get(
`${process.env.PUBLIC_URL}/api/admin/monthlyNews/${year}/${month}`, `/api/admin/monthlyNews/${year}/${month}`,
{ {
headers: { headers: {
'XSRF-TOKEN': token, 'XSRF-TOKEN': token,
...@@ -75,7 +72,7 @@ export class MonthlyNewsService { ...@@ -75,7 +72,7 @@ export class MonthlyNewsService {
): Promise<IPoll | null> => { ): Promise<IPoll | null> => {
try { try {
const { data } = await axios.get( const { data } = await axios.get(
`${process.env.PUBLIC_URL}/api/admin/poll/${year}/${month}`, `/api/admin/poll/${year}/${month}`,
{ {
headers: { headers: {
'XSRF-TOKEN': token, 'XSRF-TOKEN': token,
...@@ -103,7 +100,7 @@ export class MonthlyNewsService { ...@@ -103,7 +100,7 @@ export class MonthlyNewsService {
): Promise<void> => { ): Promise<void> => {
try { try {
await axios.put( await axios.put(
`${process.env.PUBLIC_URL}/api/admin/poll`, `/api/admin/poll`,
{ {
month: date.getMonth(), month: date.getMonth(),
year: date.getFullYear(), year: date.getFullYear(),
...@@ -135,7 +132,7 @@ export class MonthlyNewsService { ...@@ -135,7 +132,7 @@ export class MonthlyNewsService {
): Promise<void> => { ): Promise<void> => {
try { try {
await axios.delete( await axios.delete(
`${process.env.PUBLIC_URL}api/admin/poll/${year}/${month}`, `/api/admin/poll/${year}/${month}`,
{ {
headers: { headers: {
'XSRF-TOKEN': token, 'XSRF-TOKEN': token,
...@@ -161,7 +158,7 @@ export class MonthlyNewsService { ...@@ -161,7 +158,7 @@ export class MonthlyNewsService {
): Promise<void> => { ): Promise<void> => {
try { try {
await axios.delete( await axios.delete(
`${process.env.PUBLIC_URL}api/admin/monthlyNews/${year}/${month}`, `/api/admin/monthlyNews/${year}/${month}`,
{ {
headers: { headers: {
'XSRF-TOKEN': token, 'XSRF-TOKEN': token,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment