Skip to content

Commit ca3fd39

Browse files
author
epicmeme
committed
API env + Dockerfile fix
- Removed NEXT_PUBLIC_API_URL from .env and replaced with "location.origin" in code.
1 parent d1bced7 commit ca3fd39

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@ ENV DB_USERNAME=${ARG_USERNAME}
1313
ENV DB_PASSWORD=${ARG_PASSWORD}
1414
ENV DB_CLUSTER=${ARG_CLUSTER}
1515
ENV DB_DATABASE=${ARG_DATABASE}
16-
ENV MQTT_URL=${ARG_MQTT_URL}}
17-
ENV NEXT_PUBLIC_API_URL=${ARG_API_URL}
18-
19-
RUN echo "$DB_USERNAME"
20-
RUN echo "$DB_CLUSTER"
21-
RUN echo "$DB_DATABASE"
22-
RUN echo "$MQTT_URL"
23-
RUN echo "$NEXT_PUBLIC_API_URL"
16+
ENV MQTT_URL=${ARG_MQTT_URL}
2417

2518
COPY . ./
2619
RUN yarn install --pure-lockfile && yarn build

pages/collections/[id]/edit.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface Props {
1515
async function updatePile(name: string, actions: Action[], id: string) {
1616
await axios
1717
.put(
18-
location.origin + `/${id}`,
18+
location.origin + `/api/${id}`,
1919
{
2020
name,
2121
actions,
@@ -47,9 +47,7 @@ async function updatePile(name: string, actions: Action[], id: string) {
4747
}
4848

4949
export default function Edit({ pile }: Props) {
50-
return (
51-
<EditPile pile={pile} setPileCallback={updatePile}/>
52-
)
50+
return <EditPile pile={pile} setPileCallback={updatePile} />;
5351
}
5452

5553
export const getStaticProps: GetStaticProps<Props> = async (context) => {

pages/collections/create.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { NEXT_PUBLIC_API_URL } = process.env;
1010
async function createPile(name: string, actions: Action[]) {
1111
await axios
1212
.post(
13-
`${NEXT_PUBLIC_API_URL}`,
13+
`${location.origin}/api`,
1414
{
1515
name: name,
1616
actions: actions,
@@ -41,7 +41,6 @@ async function createPile(name: string, actions: Action[]) {
4141
});
4242
}
4343

44-
4544
const exampleAction: Action = {
4645
title: 'Scen på',
4746
topic: 'light_mixer/code/run',
@@ -51,12 +50,9 @@ const exampleAction: Action = {
5150
const newPile: Pile = {
5251
_id: '',
5352
name: '',
54-
actions: [exampleAction]
55-
}
53+
actions: [exampleAction],
54+
};
5655

5756
export default function Create() {
58-
59-
return (
60-
<EditPile pile={newPile} setPileCallback={createPile}/>
61-
)
57+
return <EditPile pile={newPile} setPileCallback={createPile} />;
6258
}

pages/collections/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ import { getPiles } from '../api';
99
import { showNotification } from '@mantine/notifications';
1010
import getConfig from 'next/config';
1111

12-
const { publicRuntimeConfig } = getConfig();
1312
interface Props {
1413
piles: Pile[];
1514
}
1615

1716
async function handleDelete(id: string) {
1817
await axios
19-
.delete(`${publicRuntimeConfig.apiURL}/${id}`)
18+
.delete(`${location.origin}/api/${id}`)
2019
.then((res) =>
2120
showNotification({
2221
title: 'Success',

0 commit comments

Comments
 (0)