Skip to content

Commit

Permalink
Move backend /files endpoint to /api/files
Browse files Browse the repository at this point in the history
Signed-off-by: Andrés Vidal <[email protected]>
  • Loading branch information
andres-vidal committed Jun 6, 2024
1 parent 6f87342 commit c02c04f
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Environment variables are configuration units relevant to the app's build or run
| Key | Description | Recommended value for dev |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| `NEXT_PUBLIC_API_URL` | URL of the backend server API | `http://localhost:4000/api` |
| `NEXT_PUBLIC_FILES_URL` | URL of the backend server files | `http://localhost:4000/files` |
|`NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY`| Sitekey from Google Recaptcha| Sign up for one in `http://www.google.com/recaptcha/admin`
| `NEXT_INTERNAL_API_URL` | URL of the backend server API. For use in a closed environment. Set to the same value of `NEXT_PUBLIC_API_URL` if Phoenix server public url is reachable from NextJS server. | `http://localhost:4000/api` |
| `NEXTAUTH_URL` | The canonical URL of the site ([read more](https://next-auth.js.org/configuration/options#nextauth_url)) | `http://localhost:3000` |
Expand Down
2 changes: 1 addition & 1 deletion backend/lib/richard_burton_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule RichardBurtonWeb.Router do
post("/users", UserController, :create)
end

scope "/files", RichardBurtonWeb do
scope "/api/files", RichardBurtonWeb do
pipe_through(:files)
pipe_through(:authorize_admin)

Expand Down
2 changes: 0 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ services:
target: dev
args:
NEXT_PUBLIC_API_URL: $NEXT_PUBLIC_API_URL
NEXT_PUBLIC_FILES_URL: $NEXT_PUBLIC_FILES_URL
NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY: $NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY
environment:
# Browser
NEXT_PUBLIC_API_URL: http://localhost:4000/api
NEXT_PUBLIC_FILES_URL: http://localhost:4000/files
# Server
PORT: 3000
NEXT_INTERNAL_API_URL: http://host.docker.internal:4000/api
Expand Down
1 change: 0 additions & 1 deletion docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
target: prod
args:
NEXT_PUBLIC_API_URL: $NEXT_PUBLIC_API_URL
NEXT_PUBLIC_FILES_URL: $NEXT_PUBLIC_FILES_URL
NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY: $NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY
environment:
# Server
Expand Down
1 change: 0 additions & 1 deletion frontend/.env.development
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Browser
NEXT_PUBLIC_API_URL=http://localhost:4000/api
NEXT_PUBLIC_FILES_URL=http://localhost:4000/files

# Next Server
NEXT_INTERNAL_API_URL=http://localhost:4000/api
Expand Down
2 changes: 0 additions & 2 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ RUN \
# Rebuild the source code only when needed
FROM node:21-alpine AS builder
ARG NEXT_PUBLIC_API_URL
ARG NEXT_PUBLIC_FILES_URL
ARG NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
ENV NEXT_PUBLIC_FILES_URL=$NEXT_PUBLIC_FILES_URL
ENV NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY=$NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY

WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/PublicationDownload.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FILES_URL, request } from "app";
import { request } from "app";
import DownloadIcon from "assets/download.svg";
import { snakeCase } from "lodash";
import { Publication } from "modules/publication";
Expand Down Expand Up @@ -32,7 +32,7 @@ const PublicationDownload: FC = () => {
);

const { data, headers } = await http.get(
`${FILES_URL}/publications?${query}`,
`files/publications?${query}`,
{ responseType: "blob" },
);

Expand Down
3 changes: 1 addition & 2 deletions frontend/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { RecoilRoot } from "recoil";
import "styles/globals.css";

const API_URL = process.env.NEXT_PUBLIC_API_URL;
const FILES_URL = process.env.NEXT_PUBLIC_FILES_URL;
const GOOGLE_RECAPTCHA_SITEKEY =
process.env.NEXT_PUBLIC_GOOGLE_RECAPTCHA_SITEKEY!;

Expand Down Expand Up @@ -90,4 +89,4 @@ const App: FC<AppProps> = ({ Component, pageProps }) => {
};

export default App;
export { API_URL, FILES_URL, GOOGLE_RECAPTCHA_SITEKEY, http, Key, request };
export { API_URL, GOOGLE_RECAPTCHA_SITEKEY, http, Key, request };

0 comments on commit c02c04f

Please sign in to comment.