Skip to content

Commit

Permalink
Segregated development URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie6king committed Nov 19, 2024
1 parent f98e7b9 commit e3d80b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN npm run build
# setup app
FROM node:20
WORKDIR /app
ENV NODE_ENV="production"

# install production dependencies
COPY package*.json .
Expand Down
4 changes: 2 additions & 2 deletions client/Root.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export default function Root() {

setLoading(true)

const url = "http://localhost:3000/locations"
const url = (process.env.NODE_ENV === "development") ? "http://localhost:3000/locations" : "/locations"

if (searchTimeout) clearTimeout(searchTimeout);
searchTimeout = setTimeout(async () => {
try {

const response = await fetch("http://localhost:3000/locations", {
const response = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ string: search }),
Expand Down
6 changes: 3 additions & 3 deletions client/Show.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export default function Weather() {
const fetchWeatherData = async () => {

// urls
const weatherUrl = "http://localhost:3000/weather";
const forecastUrl = "http://localhost:3000/forecast";
const airQualityUrl = "http://localhost:3000/airquality";
const weatherUrl =(process.env.NODE_ENV === "development") ? "http://localhost:3000/weather" : "/weather";
const forecastUrl = (process.env.NODE_ENV === "development") ? "http://localhost:3000/forecast" : "/forecast";
const airQualityUrl = (process.env.NODE_ENV === "development") ? "http://localhost:3000/airquality" : "/airquality";
const lat = searchParams.get("lat");
const lon = searchParams.get("lon");
const tz = tz_lookup(lat, lon)
Expand Down
1 change: 0 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ app.use(express.urlencoded({ extended: false }));
app.use((req, res, next) => {

const allowedOrigins = [
"http://localhost:3000",
"http://127.0.0.1:8080",
"http://127.0.0.1:3000"
];
Expand Down

0 comments on commit e3d80b3

Please sign in to comment.