diff --git a/.env b/.env index a09eacb..4c541f4 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ GATSBY_PATH_PREFIX=/impresso-datalab -GATSBY_IMPRESSO_API_URL=http://localhost:8000/api \ No newline at end of file +GATSBY_IMPRESSO_API_URL=http://localhost/api +GATSBY_IMPRESSO_PUBLIC_API_URL=http://localhost/public-api \ No newline at end of file diff --git a/gatsby-config.js b/gatsby-config.js index f2352fa..3be60bc 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -6,9 +6,14 @@ const { createProxyMiddleware } = require("http-proxy-middleware") require("dotenv").config({ path: [`.env.${process.env.NODE_ENV}`, ".env"], }) -const ApiHost = ( +const ApiUrl = process.env.GATSBY_IMPRESSO_API_URL || "http://localhost:8000/api" -).replace("/api", "") +const PublicApiUrl = + process.env.GATSBY_IMPRESSO_PUBLIC_API_URL || + "http://localhost:8000/public-api" + +const ApiHost = ApiUrl.replace("/api", "") +const PublicApiHost = PublicApiUrl.replace("/public-api", "") console.log("gatsby-config") console.log("NODE_ENV", process.env.NODE_ENV) @@ -19,11 +24,16 @@ console.log("GIT_BRANCH", process.env.GIT_BRANCH) console.log("GIT_REVISION", process.env.GIT_REVISION) console.log("GIT_REPO", process.env.GIT_REPO) console.log("GATSBY_IMPRESSO_API_URL", process.env.GATSBY_IMPRESSO_API_URL) -console.log("ApiHost", ApiHost) +console.log( + "GATSBY_IMPRESSO_PUBLIC_API_URL", + process.env.GATSBY_IMPRESSO_PUBLIC_API_URL, +) +console.log("- ApiHost", ApiHost) +console.log("- PublicApiHost", PublicApiHost) module.exports = { siteMetadata: { - title: `impresso-datalab`, + title: `Impresso data lab`, siteUrl: `https://impresso-project.ch/datalab`, gitBuildTag: process.env.GIT_BUILD_TAG, gitBranch: process.env.GIT_BRANCH, @@ -35,10 +45,17 @@ module.exports = { app.use( "/api/socket.io", createProxyMiddleware({ - target: "https://dev.impresso-project.ch", + target: ApiHost, ws: true, changeOrigin: true, - }) + }), + ) + app.use( + "/public-api", + createProxyMiddleware({ + target: PublicApiHost, + changeOrigin: true, + }), ) }, plugins: [ diff --git a/src/pages/AccessToApi.tsx b/src/components/AccessToApi.tsx similarity index 91% rename from src/pages/AccessToApi.tsx rename to src/components/AccessToApi.tsx index 93da3bc..99aba11 100644 --- a/src/pages/AccessToApi.tsx +++ b/src/components/AccessToApi.tsx @@ -1,12 +1,12 @@ import React, { useEffect, useRef } from "react" -import Alert from "../components/Alert" +import Alert from "./Alert" import { Button, Form } from "react-bootstrap" import { RefreshDouble, PlusCircle } from "iconoir-react" -import Token from "../components/Token" +import Token from "./Token" import { useMutation } from "@tanstack/react-query" import axios from "axios" -import UserCard from "../components/UserCard" -import LoginForm, { LoginFormPayload } from "../components/LoginForm" +import UserCard from "./UserCard" +import LoginForm, { LoginFormPayload } from "./LoginForm" export interface AccessToApiProps { llToken?: string @@ -41,6 +41,7 @@ const AccessToApi: React.FC = ({ llToken }) => { useEffect(() => { if (llToken && llToken.length > 0) { + console.info("[AccessToApi] llToken is set, calling the mutation") // call the mutation mutate({ strategy: "local", @@ -64,7 +65,7 @@ const AccessToApi: React.FC = ({ llToken }) => { {errorIsUnauthorized && ( )} - + {status} { +const Header: React.FC<{ enableSearch: string }> = ({ + enableSearch = false, +}) => { return (
- +