Rename NEXT_PUBLIC_... env variables to allow reading from env at runtime
This commit is contained in:
parent
834a38046f
commit
376220b26e
10 changed files with 22 additions and 22 deletions
|
@ -1,9 +1,9 @@
|
||||||
FROM node:alpine
|
FROM node:alpine
|
||||||
|
|
||||||
ARG NEXT_PUBLIC_WS_URL='ws://127.0.0.1:3001'
|
ARG BACKEND_WS_URL='ws://127.0.0.1:3001'
|
||||||
ARG NEXT_PUBLIC_API_URL='http://127.0.0.1:3001/api'
|
ARG BACKEND_API_URL='http://127.0.0.1:3001/api'
|
||||||
ENV NEXT_PUBLIC_WS_URL=${NEXT_PUBLIC_WS_URL}
|
ENV BACKEND_WS_URL=${BACKEND_WS_URL}
|
||||||
ENV NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL}
|
ENV BACKEND_API_URL=${BACKEND_API_URL}
|
||||||
|
|
||||||
WORKDIR /home/perplexica
|
WORKDIR /home/perplexica
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ docker compose down --rmi all
|
||||||
|
|
||||||
```
|
```
|
||||||
args:
|
args:
|
||||||
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
|
- BACKEND_API_URL=http://127.0.0.1:3001/api
|
||||||
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
|
- BACKEND_WS_URL=ws://127.0.0.1:3001
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Save and close the `docker-compose.yaml` file
|
6. Save and close the `docker-compose.yaml` file
|
||||||
|
@ -58,8 +58,8 @@ nano docker-compose.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
args:
|
args:
|
||||||
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
|
- BACKEND_API_URL=http://127.0.0.1:3001/api
|
||||||
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
|
- BACKEND_WS_URL=ws://127.0.0.1:3001
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Save and exit the editor
|
6. Save and exit the editor
|
||||||
|
@ -96,8 +96,8 @@ nano docker-compose.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
args:
|
args:
|
||||||
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
|
- BACKEND_API_URL=http://127.0.0.1:3001/api
|
||||||
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
|
- BACKEND_WS_URL=ws://127.0.0.1:3001
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Save and exit the editor
|
6. Save and exit the editor
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
NEXT_PUBLIC_WS_URL=ws://localhost:3001
|
BACKEND_WS_URL=ws://localhost:3001
|
||||||
NEXT_PUBLIC_API_URL=http://localhost:3001/api
|
BACKEND_API_URL=http://localhost:3001/api
|
|
@ -22,7 +22,7 @@ const Page = () => {
|
||||||
const fetchChats = async () => {
|
const fetchChats = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/chats`, {
|
const res = await fetch(`${process.env.BACKEND_API_URL}/chats`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
@ -40,7 +40,7 @@ const useSocket = (
|
||||||
);
|
);
|
||||||
|
|
||||||
const providers = await fetch(
|
const providers = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/models`,
|
`${process.env.BACKEND_API_URL}/models`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
@ -221,7 +221,7 @@ const loadMessages = async (
|
||||||
setNotFound: (notFound: boolean) => void,
|
setNotFound: (notFound: boolean) => void,
|
||||||
) => {
|
) => {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/chats/${chatId}`,
|
`${process.env.BACKEND_API_URL}/chats/${chatId}`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -272,7 +272,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
||||||
|
|
||||||
const [isWSReady, setIsWSReady] = useState(false);
|
const [isWSReady, setIsWSReady] = useState(false);
|
||||||
const ws = useSocket(
|
const ws = useSocket(
|
||||||
process.env.NEXT_PUBLIC_WS_URL!,
|
process.env.BACKEND_WS_URL!,
|
||||||
setIsWSReady,
|
setIsWSReady,
|
||||||
setHasError,
|
setHasError,
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,7 +21,7 @@ const DeleteChat = ({
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/chats/${chatId}`,
|
`${process.env.BACKEND_API_URL}/chats/${chatId}`,
|
||||||
{
|
{
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -35,7 +35,7 @@ const SearchImages = ({
|
||||||
const chatModel = localStorage.getItem('chatModel');
|
const chatModel = localStorage.getItem('chatModel');
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/images`,
|
`${process.env.BACKEND_API_URL}/images`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -48,7 +48,7 @@ const Searchvideos = ({
|
||||||
const chatModel = localStorage.getItem('chatModel');
|
const chatModel = localStorage.getItem('chatModel');
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${process.env.NEXT_PUBLIC_API_URL}/videos`,
|
`${process.env.BACKEND_API_URL}/videos`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -89,7 +89,7 @@ const SettingsDialog = ({
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
const fetchConfig = async () => {
|
const fetchConfig = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/config`, {
|
const res = await fetch(`${process.env.BACKEND_API_URL}/config`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
|
@ -149,7 +149,7 @@ const SettingsDialog = ({
|
||||||
setIsUpdating(true);
|
setIsUpdating(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/config`, {
|
await fetch(`${process.env.BACKEND_API_URL}/config`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
@ -5,7 +5,7 @@ export const getSuggestions = async (chatHisory: Message[]) => {
|
||||||
const chatModel = localStorage.getItem('chatModel');
|
const chatModel = localStorage.getItem('chatModel');
|
||||||
const chatModelProvider = localStorage.getItem('chatModelProvider');
|
const chatModelProvider = localStorage.getItem('chatModelProvider');
|
||||||
|
|
||||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/suggestions`, {
|
const res = await fetch(`${process.env.BACKEND_API_URL}/suggestions`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
Loading…
Add table
Reference in a new issue