Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

env: SELFHOSTED -> __SELFHOSTED

Blue Mouse60c27f87b2b6
diff --git a/web/Dockerfile b/web/Dockerfile
index c48c43116..61eefbe3e 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -23,7 +23,7 @@ ADD package.json ./
FROM base as build
ENV NODE_ENV=production \
- SELFHOSTED=true
+ __SELFHOSTED=true
RUN mkdir /app
WORKDIR /app
@@ -37,7 +37,7 @@ RUN npm run build
FROM base
ENV NODE_ENV=production \
- SELFHOSTED=true
+ __SELFHOSTED=true
RUN mkdir /app
WORKDIR /app
diff --git a/web/app/redux/constants/index.ts b/web/app/redux/constants/index.ts
index bdcb99dda..54f7b2a38 100644
--- a/web/app/redux/constants/index.ts
+++ b/web/app/redux/constants/index.ts
@@ -387,7 +387,7 @@ const isStaging = isBrowser ? window.REMIX_ENV?.STAGING : process.env.STAGING
const STAGING_API_URL = isBrowser ? window.REMIX_ENV?.API_STAGING_URL : process.env.API_STAGING_URL
const PRODUCTION_API_URL = isBrowser ? window.REMIX_ENV?.API_URL : process.env.API_URL
-export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.SELFHOSTED)
+export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : process.env.__SELFHOSTED)
export const API_URL = isSelfhosted || !isStaging ? PRODUCTION_API_URL : STAGING_API_URL
export const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URL
diff --git a/web/app/root.tsx b/web/app/root.tsx
index f30e3418e..ba3ef4755 100644
--- a/web/app/root.tsx
+++ b/web/app/root.tsx
@@ -190,7 +190,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
API_URL: process.env.API_URL,
API_STAGING_URL: process.env.API_STAGING_URL,
CDN_URL: process.env.CDN_URL,
- SELFHOSTED: process.env.SELFHOSTED,
+ SELFHOSTED: process.env.__SELFHOSTED,
STAGING: process.env.STAGING,
PADDLE_CLIENT_SIDE_TOKEN: process.env.PADDLE_CLIENT_SIDE_TOKEN,
}
diff --git a/web/app/routes/blog.tsx b/web/app/routes/blog.tsx
index 96b94df80..abd7bd598 100644
--- a/web/app/routes/blog.tsx
+++ b/web/app/routes/blog.tsx
@@ -1,11 +1,31 @@
-import type { MetaFunction } from '@remix-run/node'
+import type { LoaderFunction, MetaFunction } from '@remix-run/node'
+import { redirect } from '@remix-run/node'
import { Link, useLoaderData } from '@remix-run/react'
-import { blogLoader } from 'utils/getPosts'
import _map from 'lodash/map'
+import _isEmpty from 'lodash/isEmpty'
import _filter from 'lodash/filter'
-import { TITLE_SUFFIX } from 'redux/constants'
+import { isSelfhosted, TITLE_SUFFIX } from 'redux/constants'
+import { getBlogPosts } from 'api'
-export const loader = blogLoader
+export const loader: LoaderFunction = async () => {
+ if (isSelfhosted) {
+ return redirect('/dashboard', 302)
+ }
+
+ const data = await getBlogPosts()
+ .then((data) => {
+ return data
+ })
+ .catch((error) => {
+ console.error(error)
+ })
+
+ if (!data || _isEmpty(data)) {
+ return null
+ }
+
+ return data
+}
export const meta: MetaFunction = () => {
return [
diff --git a/web/app/utils/getPosts.ts b/web/app/utils/getPosts.ts
index 913ff86d5..7f7ae2114 100644
--- a/web/app/utils/getPosts.ts
+++ b/web/app/utils/getPosts.ts
@@ -1,7 +1,6 @@
import { marked, type Tokens } from 'marked'
import _isEmpty from 'lodash/isEmpty'
-import { LoaderFunction } from '@remix-run/node'
-import { getBlogPosts, getBlogPost, getBlogPostWithCategory } from 'api'
+import { getBlogPost, getBlogPostWithCategory } from 'api'
const renderer = new marked.Renderer()
@@ -66,19 +65,3 @@ export async function getPost(slug: string, category?: string): Promise<IPost |
nickname: post.attributes?.nickname,
}
}
-
-export const blogLoader: LoaderFunction = async () => {
- const data = await getBlogPosts()
- .then((data) => {
- return data
- })
- .catch((error) => {
- console.error(error)
- })
-
- if (!data || _isEmpty(data)) {
- return null
- }
-
- return data
-}
diff --git a/web/package.json b/web/package.json
index 2319113eb..90ef0f17a 100644
--- a/web/package.json
+++ b/web/package.json
@@ -1,6 +1,7 @@
{
"private": true,
"sideEffects": false,
+ "license": "AGPL-3.0",
"scripts": {
"build": "remix build",
"dev": "remix dev",