diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 474e677..292f7fc 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,6 +12,8 @@ jobs: build_and_deploy: name: Build, push and deploy runs-on: ubuntu-latest + env: + REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} permissions: contents: read id-token: write diff --git a/lps-client-frontend/src/FiltererInntektsmeldinger.js b/lps-client-frontend/src/FiltererInntektsmeldinger.js index e3f8ac5..c5deaaa 100644 --- a/lps-client-frontend/src/FiltererInntektsmeldinger.js +++ b/lps-client-frontend/src/FiltererInntektsmeldinger.js @@ -30,9 +30,9 @@ function FiltererInntektsmeldinger() { const handleSecondFormSubmit = async () => { try { setError(null); - await checkAndRefreshToken(); + // await checkAndRefreshToken(); const token = localStorage.getItem('token'); - const response = await axios.post('https://hag-lps-api-client.ekstern.dev.nav.no/filterInntektsmeldingerToken', secondFormData, { + const response = await axios.post(`${process.env.REACT_APP_BASE_URL}/filterInntektsmeldingerToken`, secondFormData, { headers: { "authorization": `${token}`, 'Content-Type': 'application/x-www-form-urlencoded' diff --git a/lps-client-frontend/src/LoginForm.js b/lps-client-frontend/src/LoginForm.js index 14add3b..f425cbe 100644 --- a/lps-client-frontend/src/LoginForm.js +++ b/lps-client-frontend/src/LoginForm.js @@ -4,7 +4,7 @@ import axios from 'axios'; import { useNavigate } from 'react-router-dom'; function LoginForm() { - const [formData, setFormData] = useState({ kid: '', privateKey: '', issuer: '', consumerOrgNr: '' }); + const [formData, setFormData] = useState({ kid: '', privateKey: '', issuer: '', orgnr: '' }); const [error, setError] = useState(null); const navigate = useNavigate(); @@ -17,17 +17,16 @@ function LoginForm() { const handleSubmit = async () => { try { - const response = await axios.post('https://hag-lps-api-client.ekstern.dev.nav.no/getToken', new URLSearchParams(formData), { + const response = await axios.post(`${process.env.REACT_APP_BASE_URL}/systembruker`, new URLSearchParams(formData), { headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, }); - localStorage.setItem('token', response.data.tokenResponse.access_token); - localStorage.setItem('exp', Date.now() + response.data.tokenResponse.expires_in * 1000); - localStorage.setItem('kid', formData.kid); - localStorage.setItem('privateKey', formData.privateKey); - localStorage.setItem('issuer', formData.issuer); - localStorage.setItem('consumerOrgNr', formData.consumerOrgNr); + console.log(response.data); + localStorage.setItem('token', response.data); + // localStorage.setItem('exp', Date.now() + response.data.tokenResponse.expires_in * 1000); + localStorage.setItem('consumerOrgNr', formData.orgnr); + console.log('Token:', response.data); navigate('/search'); } catch (error) { setError('Error submitting form'); @@ -37,7 +36,7 @@ function LoginForm() { const handleRegistrerNyBedrift = async () => { try { const response = await axios.post('http://localhost:8080/registrer-ny-bedrift', { - kundeOrgnr: formData.consumerOrgNr, + kundeOrgnr: formData.orgnr, }, { headers: { 'Content-Type': 'application/x-www-form-urlencoded', @@ -59,8 +58,8 @@ function LoginForm() {