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 @@
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:8000",
"eslintConfig": {
"extends": [
"react-app",
......
import React from "react";
import React, { useState } from "react";
import logo from "./logo.svg";
import "./App.css";
import { appTimezone, appVersion, appTheme } from "./appConfig";
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 (
<div className="App">
<header className="App-header">
......@@ -27,6 +46,7 @@ const App = () => {
<br />
Theme {appTheme}
<br />
API reachable? {apiHealth}
</p>
</header>
</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