]> Untitled Git - lemmy-ui.git/commitdiff
Fix things not working in production build
authorabias <abias1122@gmail.com>
Mon, 15 May 2023 03:45:21 +0000 (23:45 -0400)
committerabias <abias1122@gmail.com>
Mon, 15 May 2023 03:45:21 +0000 (23:45 -0400)
Dockerfile
dev.dockerfile
package.json
src/server/index.tsx
yarn.lock

index 0a23ea897b00c8fb118cac744d12f5d39ad1d971..3d6d6212d8dc4401373873cf3d9bb67cf5cfbecb 100644 (file)
@@ -7,7 +7,6 @@ WORKDIR /usr/src/app
 ENV npm_config_target_arch=x64\r
 ENV npm_config_target_platform=linux\r
 ENV npm_config_target_libc=musl\r
-ENV NODE_ENV=production\r
 \r
 # Cache deps\r
 COPY package.json yarn.lock ./\r
index 0faa3ad3dbf84c228914031e2869d4397bd094d3..0e925c0a90dfca99dceb40c7186bc82e79fb757d 100644 (file)
@@ -6,7 +6,6 @@ WORKDIR /usr/src/app
 ENV npm_config_target_arch=x64\r
 ENV npm_config_target_platform=linux\r
 ENV npm_config_target_libc=musl\r
-ENV NODE_ENV=development\r
 \r
 # Cache deps\r
 COPY package.json yarn.lock ./\r
index 332b888df862274ac67cdce2e5ca515fbd0d6648..0315416027d1af803bd2bd8fdc3ccdb315d5cdb3 100644 (file)
@@ -61,6 +61,7 @@
     "isomorphic-cookie": "^1.2.4",
     "jwt-decode": "^3.1.2",
     "lemmy-js-client": "0.17.2-rc.15",
+    "lodash": "^4.17.21",
     "markdown-it": "^13.0.1",
     "markdown-it-container": "^3.0.0",
     "markdown-it-emoji": "^2.0.2",
@@ -77,6 +78,7 @@
     "sass": "^1.62.1",
     "sass-loader": "^13.2.2",
     "serialize-javascript": "^6.0.1",
+    "service-worker-webpack": "^1.0.0",
     "sharp": "^0.32.1",
     "tippy.js": "^6.3.7",
     "toastify-js": "^1.12.0",
     "prettier-plugin-organize-imports": "^3.2.2",
     "prettier-plugin-packagejson": "^2.4.3",
     "rimraf": "^5.0.0",
-    "service-worker-webpack": "^1.0.0",
     "sortpack": "^2.3.4",
     "style-loader": "^3.3.2",
     "terser": "^5.17.3",
index 5e9b31932ae41da7409ca5bb22f1bc8f95d5f599..952bbded6d588c02f2473bb43d6b52cf9ffbe59a 100644 (file)
@@ -27,8 +27,6 @@ import {
   isAuthPath,
 } from "../shared/utils";
 
-const { NODE_ENV } = process.env as Record<string, string>;
-
 const server = express();
 const [hostname, port] = process.env["LEMMY_UI_HOST"]
   ? process.env["LEMMY_UI_HOST"].split(":")
@@ -184,7 +182,7 @@ server.get("/*", async (req, res) => {
     const isoData: IsoDataOptionalSite = {
       path,
       site_res: site,
-      routeData,
+      routeData: getErrorRouteData("lel", site),
     };
 
     const wrapper = (
@@ -200,7 +198,9 @@ server.get("/*", async (req, res) => {
     // If an error is caught here, the error page couldn't even be rendered
     console.error(err);
     res.statusCode = 500;
-    return res.send(NODE_ENV === "development" ? err.message : "Server error");
+    return res.send(
+      process.env.NODE_ENV === "development" ? err.message : "Server error"
+    );
   }
 });
 
@@ -295,9 +295,11 @@ async function fetchIconPng(iconUrl: string) {
 function getErrorRouteData(error: string, site?: GetSiteResponse) {
   const errorPageData: ErrorPageData = { type: "error" };
 
+  console.log(`Error: ${process.env.NODE_ENV}`);
+
   // Exact error should only be seen in a development environment. Users
   // in production will get a more generic message.
-  if (NODE_ENV === "development") {
+  if (process.env.NODE_ENV === "development") {
     errorPageData.error = error;
   }
 
index 62da0d1e327b0a16515e57bbffaf300a0cb0ef45..8291f2808c82e831ec17d3db27349586190f03b7 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -5546,7 +5546,7 @@ lodash@^3.10.1:
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
   integrity sha512-9mDDwqVIma6OZX79ZlDACZl8sBm0TEnkf99zV3iMA4GzkIT/9hiqP5mY0HoT1iNLCrKc/R1HByV+yJfRWVJryQ==
 
-lodash@^4.17.20:
+lodash@^4.17.20, lodash@^4.17.21:
   version "4.17.21"
   resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
   integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==