Skip to content
Snippets Groups Projects
Commit 9d9db315 authored by Jonas Braathen's avatar Jonas Braathen
Browse files

Proxy requests to backend

parent 518de43f
No related branches found
No related tags found
1 merge request!45Switch from next.js to create-react-app
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
"proxy": "http://localhost:8000",
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
"react-app", "react-app",
......
import React from "react"; import React, { useState } from "react";
import logo from "./logo.svg"; import logo from "./logo.svg";
import "./App.css"; import "./App.css";
import { appTimezone, appVersion, appTheme } from "./appConfig"; import { appTimezone, appVersion, appTheme } from "./appConfig";
const App = () => { const App = () => {
const [apiHealth, setApiHealth] = useState("not yet");
const [didContactApi, setDidContactApi] = useState(false);
if (!didContactApi) {
setDidContactApi(true);
fetch("http://localhost:3000/api/health/")
.then((res) => res.text())
.then((result) => {
if (result === "OK") {
setApiHealth("yes");
} else {
setApiHealth(result);
}
})
.catch((error) => {
setApiHealth("error");
console.log(error);
});
}
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <header className="App-header">
...@@ -27,6 +46,7 @@ const App = () => { ...@@ -27,6 +46,7 @@ const App = () => {
<br /> <br />
Theme {appTheme} Theme {appTheme}
<br /> <br />
API reachable? {apiHealth}
</p> </p>
</header> </header>
</div> </div>
......
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