This commit is contained in:
2023-05-24 15:10:34 +03:00
parent 5f09fa2490
commit 8ddf1aef53
5 changed files with 12 additions and 10 deletions

View File

@ -14,8 +14,6 @@ services:
context: react
ports:
- "3000"
environment:
- WDS_SOCKET_PORT=0
volumes:
- ./react/app:/app:z
# - ./docker_cache/node_modules:/app/node_modules

View File

@ -1,5 +1,11 @@
FROM node:20.1
ENV CI=true
ENV PORT=3000
ENV HOST=0.0.0.0
ENV WDS_SOCKET_PORT=0
ENV REACT_APP_DOMAIN=127.0.0.1
WORKDIR /app
COPY /app /app
# COPY package.json /app/package.json
@ -10,8 +16,6 @@ RUN npm ci
# COPY . /app
#
ENV CI=true
ENV PORT=3000
ENV HOST=0.0.0.0
RUN printenv
CMD [ "npm", "start" ]

View File

@ -15,7 +15,7 @@ const Snippet = ({ id }) => {
const { authTokens } = useContext(AuthContext);
const [ snippet, setSnippet ] = useState("");
const getSnippet = async (id) => {
const response = await fetch(`http://127.0.0.1/api/snippets/${id}`, {
const response = await fetch(`http://${process.env.REACT_APP_DOMAIN}/api/snippets/${id}`, {
method: "GET",
headers: {
"Authorization": `Bearer ${authTokens.access}`,
@ -31,7 +31,7 @@ const Snippet = ({ id }) => {
}
};
const updateSnippet = async (id, snippet) => {
const response = await fetch(`http://127.0.0.1/api/snippets/${id}`, {
const response = await fetch(`http://${process.env.REACT_APP_DOMAIN}/api/snippets/${id}`, {
method: "POST",
headers: {
"Authorization": `Bearer ${authTokens.access}`,

View File

@ -22,7 +22,7 @@ export const AuthProvider = ({ children }) => {
const history = useNavigate();
const loginUser = async (username, password) => {
const response = await fetch("http://127.0.0.1/api/auth/token/", {
const response = await fetch(`http://${process.env.REACT_APP_DOMAIN}/api/auth/token/`, {
method: "POST",
headers: {
"Content-Type": "application/json"
@ -46,7 +46,7 @@ export const AuthProvider = ({ children }) => {
};
const registerUser = async (username, password, password2) => {
const response = await fetch("http://127.0.0.1/api/auth/register/", {
const response = await fetch(`http://${process.env.REACT_APP_DOMAIN}/api/auth/register/`, {
method: "POST",
headers: {
"Content-Type": "application/json"

View File

@ -4,7 +4,7 @@ import dayjs from "dayjs";
import { useContext } from "react";
import AuthContext from "../context/AuthContext";
const baseURL = "http://127.0.0.1/api/auth";
const baseURL = `http://${process.env.REACT_APP_DOMAIN}/api/auth`;
const useAxios = () => {
const { authTokens, setUser, setAuthTokens } = useContext(AuthContext);