Update for Nuxt 3: Remove dotenv, and replace all usage with runtimeConfig, per https://nuxt.com/docs/guide/going-further/runtime-config#exposing-runtime-config and https://serversideup.net/using-environment-variables-in-nuxt-3/
diff --git a/components/Podcast/PodcastContentCard.vue b/components/Podcast/PodcastContentCard.vue
index 1be10b1..ee7057e 100644
--- a/components/Podcast/PodcastContentCard.vue
+++ b/components/Podcast/PodcastContentCard.vue
@@ -73,6 +73,8 @@ USED UP!
</template>
<script>
+import {useRuntimeConfig} from "nuxt/app";
+
export default {
props: {
podcastData: {
@@ -91,7 +93,8 @@ export default {
},
getEpisodeFeaturedImageUrl() {
if (this.podcastData.episode_featured_image) {
- return process.env.backendApiUrl + this.podcastData.episode_featured_image.url;
+ const runtimeConfig = useRuntimeConfig();
+ return runtimeConfig.backendApiUrl + this.podcastData.episode_featured_image.url;
}
return null;
}
diff --git a/components/Unused/SocialLogin.vue b/components/Unused/SocialLogin.vue
index e2ce498..ef9c057 100755
--- a/components/Unused/SocialLogin.vue
+++ b/components/Unused/SocialLogin.vue
@@ -63,10 +63,13 @@
</template>
<script>
+import {useRuntimeConfig} from "nuxt/app";
+
export default {
methods: {
socialLogin(service) {
- window.location.href = process.env.backendApiUrl + `/api/v1/auth/login/${service}`;
+ const runtimeConfig = useRuntimeConfig();
+ window.location.href = runtimeConfig.backendApiUrl + `/api/v1/auth/login/${service}`;
}
}
}
diff --git a/middleware/hideTestRoutes.js b/middleware/hideTestRoutes.js
index 4ae39e9..0b9a963 100644
--- a/middleware/hideTestRoutes.js
+++ b/middleware/hideTestRoutes.js
@@ -1,9 +1,13 @@
// This middleware file, if activated for a page, protects 'test' pages and routes on production and redirects them
// Note: middleware kicks in only if specified globally in nuxt.config.js, or in a .vue component file or page (example: middleware: "hideTestRoutes",)
// See https://nuxtjs.org/guide/routing#middleware
+import {useRuntimeConfig} from "nuxt/app";
+
export default function (context) {
let hiddenEnvNames = ["prod", "production", "stage", "staging"];
- if ((hiddenEnvNames.indexOf(process.env.MY_ENV_NAME) > -1) || (process.env.MY_ENV_NAME == "local" && !process.env.showExperimentalCode)) {
+
+ const runtimeConfig = useRuntimeConfig();
+ if ((hiddenEnvNames.indexOf(process.env.MY_ENV_NAME) > -1) || (process.env.MY_ENV_NAME === "local" && !runtimeConfig.showExperimentalCode)) {
// show an alert if using client-side-navigation (won't work for SSR, so we do this check first)
if (process.client) {
alert("We're sorry! You don't have permission to access that page");
diff --git a/nuxt.config.js b/nuxt.config.js
index c6bb93f..c4029c0 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -1,22 +1,25 @@
-require("dotenv").config();
const backendApiUrl = process.env.MY_BACKEND_API_URL || "http://localhost:8000";
const frontendClientUrl = process.env.MY_FRONTEND_CLIENT_URL || "http://localhost:3000";
const envName = process.env.MY_ENV_NAME || "production";
const backendPublicApiPrefix = process.env.MY_BACKEND_PUBLIC_API_PREFIX;
const stripePublishableKey = process.env.STRIPE_PUBLISHABLE_KEY || "xxxxxxxxxxxxxxxx";
-export default {
+export default defineNuxtConfig({
mode: "universal",
- // Nuxt.js lets you create environment variables that will be shared for the client and server-side.
- // See https://nuxtjs.org/api/configuration-env
- env: {
+ // Note: In Nuxt 2 (OLD): See https://nuxtjs.org/api/configuration-env Nuxt.js lets you create environment variables that will be shared for the client and server-side.
+ // private and public runtimeConfig, per https://nuxt.com/docs/migration/runtime-config#example
+ runtimeConfig: {
+ // Private config that is only available on the server
siteUrl: frontendClientUrl,
backendApiUrl: backendApiUrl,
backendPublicApiPrefix: backendPublicApiPrefix,
- environmentName: envName,
showExperimentalCode: 1, // Note: this flag only works if MY_ENV_NAME='local'
- stripePublishableKey: stripePublishableKey
+
+ // Config within public will be also exposed to the client
+ public: {
+ stripePublishableKey: stripePublishableKey
+ }
},
// 'dev' defines the development or production mode of Nuxt.js
@@ -61,8 +64,6 @@ export default {
** Nuxt.js modules
*/
modules: [
- "@nuxtjs/pwa",
- "@nuxtjs/dotenv",
"@nuxtjs/toast",
// With options, see https://www.npmjs.com/package/cookie-universal-nuxt
@@ -206,4 +207,4 @@ export default {
{ property: "fb:pages", content: "" }
]
}
-};
+});
diff --git a/package-lock.json b/package-lock.json
index cf896ca..a5a5a7e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4699,9 +4699,9 @@
}
},
"node_modules/core-js": {
- "version": "3.31.1",
- "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.31.1.tgz",
- "integrity": "sha512-2sKLtfq1eFST7l7v62zaqXacPc7uG8ZAya8ogijLhTtaKNcpzpB4TMoTw2Si+8GYKRwFPMMtUT0263QFWFfqyQ==",
+ "version": "3.32.0",
+ "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.32.0.tgz",
+ "integrity": "sha512-rd4rYZNlF3WuoYuRIDEmbR/ga9CeuWX9U05umAvgrrZoHY4Z++cp/xwPQMvUpBB4Ag6J8KfD80G0zwCyaSxDww==",
"hasInstallScript": true,
"funding": {
"type": "opencollective",
@@ -5233,9 +5233,9 @@
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/electron-to-chromium": {
- "version": "1.4.473",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.473.tgz",
- "integrity": "sha512-aVfC8+440vGfl06l8HKKn8/PD5jRfSnLkTTD65EFvU46igbpQRri1gxSzW9/+TeUlwYzrXk1sw867T96zlyECA=="
+ "version": "1.4.475",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.475.tgz",
+ "integrity": "sha512-mTye5u5P98kSJO2n7zYALhpJDmoSQejIGya0iR01GpoRady8eK3bw7YHHnjA1Rfi4ZSLdpuzlAC7Zw+1Zu7Z6A=="
},
"node_modules/emoji-regex": {
"version": "8.0.0",
@@ -7612,9 +7612,9 @@
}
},
"node_modules/magic-string": {
- "version": "0.30.1",
- "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.1.tgz",
- "integrity": "sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==",
+ "version": "0.30.2",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.2.tgz",
+ "integrity": "sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug==",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
},
diff --git a/pages/_user/_post/comments.vue b/pages/_user/_post/comments.vue
index b8b7786..b6fa23c 100644
--- a/pages/_user/_post/comments.vue
+++ b/pages/_user/_post/comments.vue
@@ -110,6 +110,7 @@
<script>
import PostCommentTree from "@/components/Post/PostCommentTree.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -220,6 +221,7 @@ export default {
async asyncData (context) {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
+ const runtimeConfig = useRuntimeConfig();
let authorSlug = context.params.user ? context.params.user : null;
let postSlug = context.params.post ? context.params.post : null;
if (!authorSlug || !postSlug) {
@@ -228,7 +230,7 @@ export default {
}
// get data about the user
- let userApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/users/' + authorSlug);
+ let userApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/users/' + authorSlug);
if (!userApiResponse || !userApiResponse.data || !userApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -236,7 +238,7 @@ export default {
userObj = myGlobalConstants.globalUtilityFunctions.sanitizeUserAndProfile(userObj);
// Get data for the post
- let postsApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/posts/' + authorSlug + "/" + postSlug + "?comments=all");
+ let postsApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/posts/' + authorSlug + "/" + postSlug + "?comments=all");
if (!postsApiResponse || !postsApiResponse.data || !postsApiResponse.data.data) {
// post was not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
diff --git a/pages/_user/_post/delete_confirm.vue b/pages/_user/_post/delete_confirm.vue
index 17cc6ca..df1936c 100644
--- a/pages/_user/_post/delete_confirm.vue
+++ b/pages/_user/_post/delete_confirm.vue
@@ -64,6 +64,7 @@
<script>
import PostCommentTree from "@/components/Post/PostCommentTree.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -174,7 +175,8 @@ export default {
}
// get data about the user
- let userApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/users/' + authorSlug);
+ const runtimeConfig = useRuntimeConfig();
+ let userApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/users/' + authorSlug);
if (!userApiResponse || !userApiResponse.data || !userApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
diff --git a/pages/_user/_post/index.vue b/pages/_user/_post/index.vue
index 72874e0..74ae30b 100644
--- a/pages/_user/_post/index.vue
+++ b/pages/_user/_post/index.vue
@@ -298,6 +298,7 @@ import myGlobalConstants from '@/plugins/myGlobalConstants';
import FollowUserButton from "@/components/partials/FollowUserButton.vue";
import SponsorYourBrandCard from "@/components/partials/SponsorYourBrandCard.vue";
import PostCommentBox from "@/components/Post/PostCommentBox.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -477,6 +478,7 @@ export default {
async asyncData (context) {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
+ const runtimeConfig = useRuntimeConfig();
let authorSlug = context.params.user ? context.params.user : null;
let postSlug = context.params.post ? context.params.post : null;
if (!authorSlug || !postSlug) {
@@ -485,7 +487,7 @@ export default {
}
// Get data about the user. This API call is needed to get the detailed user profile data that is not available in the Post API response
- let userApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/users/' + authorSlug);
+ let userApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/users/' + authorSlug);
if (!userApiResponse || !userApiResponse.data || !userApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -493,7 +495,7 @@ export default {
userObj = myGlobalConstants.globalUtilityFunctions.sanitizeUserAndProfile(userObj);
// Get data for the post
- let postsApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/posts/' + authorSlug + "/" + postSlug + "?comments");
+ let postsApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/posts/' + authorSlug + "/" + postSlug + "?comments");
if (!postsApiResponse || !postsApiResponse.data || !postsApiResponse.data.data) {
// post was not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
@@ -505,7 +507,7 @@ export default {
let sanitizedPost = myGlobalConstants.globalUtilityFunctions.sanitizePost(returnedPost);
// get data for user's other posts (for this API call, we dont need the current logged-in user's bookmarks)
- let userPostsApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/posts?username=' + authorSlug + '&viewBy=latest');
+ let userPostsApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/posts?username=' + authorSlug + '&viewBy=latest');
if (!userPostsApiResponse || !userPostsApiResponse.data || !userPostsApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
diff --git a/pages/_user/comment/_comment/delete_confirm.vue b/pages/_user/comment/_comment/delete_confirm.vue
index 215b9f3..9c4d516 100755
--- a/pages/_user/comment/_comment/delete_confirm.vue
+++ b/pages/_user/comment/_comment/delete_confirm.vue
@@ -84,6 +84,7 @@
<script>
import myGlobalConstants from '@/plugins/myGlobalConstants';
import PostCommentTree from "@/components/Post/PostCommentTree.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -226,7 +227,8 @@ export default {
}
// Get data for the comment
- let commentApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
+ const runtimeConfig = useRuntimeConfig();
+ let commentApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
if (!commentApiResponse || !commentApiResponse.data || !commentApiResponse.data.data) {
// comment was not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
diff --git a/pages/_user/comment/_comment/edit.vue b/pages/_user/comment/_comment/edit.vue
index 0c24f9b..3550ebc 100755
--- a/pages/_user/comment/_comment/edit.vue
+++ b/pages/_user/comment/_comment/edit.vue
@@ -105,6 +105,7 @@
<script>
import Form from 'vform';
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -208,7 +209,8 @@ export default {
}
// Get data for the comment
- let commentApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
+ const runtimeConfig = useRuntimeConfig();
+ let commentApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
if (!commentApiResponse || !commentApiResponse.data || !commentApiResponse.data.data) {
// comment was not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
diff --git a/pages/_user/comment/_comment/index.vue b/pages/_user/comment/_comment/index.vue
index bafb2ce..f764c30 100644
--- a/pages/_user/comment/_comment/index.vue
+++ b/pages/_user/comment/_comment/index.vue
@@ -58,6 +58,7 @@
<script>
import myGlobalConstants from '@/plugins/myGlobalConstants';
import PostCommentTree from "@/components/Post/PostCommentTree.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -123,7 +124,8 @@ export default {
}
// Get data for the comment
- let commentApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
+ const runtimeConfig = useRuntimeConfig();
+ let commentApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/comments/' + commentAuthorHandle + "/" + commentHash + "?nested");
if (!commentApiResponse || !commentApiResponse.data || !commentApiResponse.data.data) {
// comment was not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
diff --git a/pages/_user/comments.vue b/pages/_user/comments.vue
index 0812763..6e5b664 100644
--- a/pages/_user/comments.vue
+++ b/pages/_user/comments.vue
@@ -13,6 +13,7 @@
<script>
import UserComments from "@/components/UserProfile/Comments/UserComments.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -51,7 +52,8 @@ export default {
}
// Get data for the comments
- let commentApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/comments/' + commentAuthorHandle);
+ const runtimeConfig = useRuntimeConfig();
+ let commentApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/comments/' + commentAuthorHandle);
if (!commentApiResponse || !commentApiResponse.data || !commentApiResponse.data.data) {
// comments not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
diff --git a/pages/_user/index.vue b/pages/_user/index.vue
index 84e3c6d..9994a43 100644
--- a/pages/_user/index.vue
+++ b/pages/_user/index.vue
@@ -105,6 +105,7 @@ import FollowPeopleWidget from "@/components/UserFollowPeople/FollowPeopleWidget
import SiteAboutUsCard from "@/components/Site/AboutUsCard.vue";
import dayjs from 'dayjs';
import InfiniteLoad from "~/components/InfiniteLoader.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -167,6 +168,7 @@ export default {
// See https://nuxtjs.org/guide/async-data/#using-async-await
async asyncData (context) {
try {
+ const runtimeConfig = useRuntimeConfig();
let userHandle = context.params.user ? context.params.user : null;
if (!userHandle) {
// parameters were not passed in correctly
@@ -174,7 +176,7 @@ export default {
}
// Get data about the user. This API call is needed to get the detailed user profile data that is not available in the Post API response
- let userApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/users/' + userHandle);
+ let userApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/users/' + userHandle);
if (!userApiResponse || !userApiResponse.data || !userApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -183,7 +185,7 @@ export default {
// Get data for user comments
let totalUserCommentsCount = 0;
- let commentApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/comments/' + userHandle + "?maxComments=5");
+ let commentApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/comments/' + userHandle + "?maxComments=5");
if (!commentApiResponse || !commentApiResponse.data || !commentApiResponse.data.data) {
// comments not found
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist..' });
@@ -199,7 +201,7 @@ export default {
let postsByUserApiUrl = null;
if (!context.store.getters.isAuthenticated) {
// get data for author posts (feed), and append the empty bookmarks / reactions, since the user is not logged in
- postsByUserApiUrl = '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?username=' + userHandle;
+ postsByUserApiUrl = '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?username=' + userHandle;
} else {
// get data for author posts (feed), and append the currently logged-in user's bookmarked posts
postsByUserApiUrl = '/me/getPostsWithMyReactions?username=' + userHandle;
@@ -255,9 +257,10 @@ export default {
postsUrl() {
// API endpoint to get data for user posts (feed) and currently logged-in user's bookmarked posts
+ const runtimeConfig = useRuntimeConfig();
let userHandle = this.$route.params.user ? this.$route.params.user : null;
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?username=' + userHandle;
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?username=' + userHandle;
} else {
return '/me/getPostsWithMyReactions?username=' + userHandle;
}
diff --git a/pages/contact.vue b/pages/contact.vue
index 1f82be0..159b995 100644
--- a/pages/contact.vue
+++ b/pages/contact.vue
@@ -55,17 +55,20 @@
</template>
<script>
+import {useRuntimeConfig} from "nuxt/app";
+
export default {
layout: "default",
components: {},
data() {
+ const runtimeConfig = useRuntimeConfig();
return {
fields: {},
errors: {},
success: false,
loaded: true,
//action: '',
- 'action': '/' + process.env.backendPublicApiPrefix + '/contact-forms',
+ 'action': '/' + runtimeConfig.backendPublicApiPrefix + '/contact-forms',
}
},
methods: {
diff --git a/pages/index.vue b/pages/index.vue
index ba7f0e2..551f63e 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -62,6 +62,7 @@ import UserProfileCard from "@/components/UserProfile/UserProfileCard.vue";
import NotLoggedInSignupCard from "@/components/UserProfile/NotLoggedInSignupCard.vue";
import SiteAboutUsCard from "@/components/Site/AboutUsCard.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -126,11 +127,12 @@ export default {
async asyncData (context) {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
+ const runtimeConfig = useRuntimeConfig();
let userObj = null;
if (context.store.getters.isAuthenticated && context.store.getters.username) {
// Get data about the user
let userHandle = context.store.getters.username;
- let userApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/users/' + userHandle);
+ let userApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/users/' + userHandle);
if (!userApiResponse || !userApiResponse.data || !userApiResponse.data.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -140,8 +142,8 @@ export default {
// Get data for user's followed tags
let userFollowedTags = [];
- if (!context.store.getters.getUserTags || (context.store.getters.getUserTags.length == 0) ) {
- let myTagsResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/userTags');
+ if (!context.store.getters.getUserTags || (context.store.getters.getUserTags.length === 0) ) {
+ let myTagsResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/userTags');
if (!myTagsResponse || !myTagsResponse.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -154,7 +156,7 @@ export default {
let tagStreams = [];
let popularTags = [];
- let tagStreamsApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/tagStreams');
+ let tagStreamsApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tagStreams');
if (tagStreamsApiResponse && tagStreamsApiResponse.data && tagStreamsApiResponse.data.data) {
tagStreams = tagStreamsApiResponse.data.data.featured_tags ? tagStreamsApiResponse.data.data.featured_tags : [];
popularTags = tagStreamsApiResponse.data.data.popular_tags ? tagStreamsApiResponse.data.data.popular_tags : [];
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 9750a49..5fa21f3 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -10,6 +10,7 @@
<script>
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
@@ -20,7 +21,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
} else {
return '/me/getPostsWithMyReactions?dummyParam=1';
}
@@ -32,7 +34,8 @@ export default {
// See https://wildermuth.com/2019/04/22/Vuex-and-Asynchronicity
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': 'feed'} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': 'feed'} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1', 'selection': 'feed'} );
}
diff --git a/pages/index/latest.vue b/pages/index/latest.vue
index f18180e..d7d5e11 100644
--- a/pages/index/latest.vue
+++ b/pages/index/latest.vue
@@ -9,6 +9,7 @@
<script>
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
@@ -18,7 +19,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
} else {
return '/me/getPostsWithMyReactions?dummyParam=1';
}
@@ -35,7 +37,8 @@ export default {
// See https://wildermuth.com/2019/04/22/Vuex-and-Asynchronicity
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': 'latest'} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': 'latest'} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1', 'selection': 'latest'} );
}
diff --git a/pages/index/top/_slug.vue b/pages/index/top/_slug.vue
index 301c57a..00dd821 100644
--- a/pages/index/top/_slug.vue
+++ b/pages/index/top/_slug.vue
@@ -10,6 +10,7 @@
<script>
import myGlobalConstants from '@/plugins/myGlobalConstants';
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
@@ -36,7 +37,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1';
} else {
return '/me/getPostsWithMyReactions?dummyParam=1';
}
@@ -71,7 +73,8 @@ export default {
// See https://wildermuth.com/2019/04/22/Vuex-and-Asynchronicity
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': currentSelection} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1', 'selection': currentSelection} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1', 'selection': currentSelection} );
}
diff --git a/pages/podcast/_slug.vue b/pages/podcast/_slug.vue
index 98c9a14..563b1a0 100644
--- a/pages/podcast/_slug.vue
+++ b/pages/podcast/_slug.vue
@@ -284,6 +284,7 @@ import myGlobalConstants from '@/plugins/myGlobalConstants';
import SubscribeWidget from "@/components/Podcast/SubscribeWidget.vue";
import WavesCanvas from "@/components/Podcast/WaveAnimation/WavesCanvas.vue";
import SponsorYourBrandCard from "@/components/partials/SponsorYourBrandCard.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
components: {
@@ -369,13 +370,15 @@ export default {
},
getSpeakerImageUrl() {
if (this.podcastEpisodeData.podcast_episode_speaker && this.podcastEpisodeData.podcast_episode_speaker.speaker_image) {
- return process.env.backendApiUrl + this.podcastEpisodeData.podcast_episode_speaker.speaker_image.url;
+ const runtimeConfig = useRuntimeConfig();
+ return runtimeConfig.backendApiUrl + this.podcastEpisodeData.podcast_episode_speaker.speaker_image.url;
}
return null;
},
getEpisodeFeaturedImageUrl() {
if (this.podcastEpisodeData.episode_featured_image) {
- return process.env.backendApiUrl + this.podcastEpisodeData.episode_featured_image.url;
+ const runtimeConfig = useRuntimeConfig();
+ return runtimeConfig.backendApiUrl + this.podcastEpisodeData.episode_featured_image.url;
}
return null;
}
@@ -391,7 +394,8 @@ export default {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
let podcastSlug = context.params.slug;
- let podcastEpisodeDataResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/podcast-episodes/' + podcastSlug);
+ const runtimeConfig = useRuntimeConfig();
+ let podcastEpisodeDataResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/podcast-episodes/' + podcastSlug);
if (!podcastEpisodeDataResponse) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
diff --git a/pages/podcast/index.vue b/pages/podcast/index.vue
index 9018762..5cae1bb 100644
--- a/pages/podcast/index.vue
+++ b/pages/podcast/index.vue
@@ -60,6 +60,7 @@
<script>
import WavesCanvas from "@/components/Podcast/WaveAnimation/WavesCanvas.vue";
import PodcastContentCard from "@/components/Podcast/PodcastContentCard.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -77,7 +78,8 @@ export default {
async asyncData (context) {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
- let allPodcastsDataResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/podcast-episodes/');
+ const runtimeConfig = useRuntimeConfig();
+ let allPodcastsDataResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/podcast-episodes/');
if (!allPodcastsDataResponse) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
diff --git a/pages/search.vue b/pages/search.vue
index b61be0c..98d26b7 100644
--- a/pages/search.vue
+++ b/pages/search.vue
@@ -54,6 +54,7 @@ import SiteAboutUsCard from "@/components/Site/AboutUsCard.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
import { mapMutations } from 'vuex';
+import {useRuntimeConfig} from "nuxt/app";
export default {
layout: "default",
@@ -91,8 +92,9 @@ export default {
try {
// Get data for user's followed tags
let userFollowedTags = [];
- if (!context.store.getters.getUserTags || (context.store.getters.getUserTags.length == 0) ) {
- let myTagsResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/userTags');
+ const runtimeConfig = useRuntimeConfig();
+ if (!context.store.getters.getUserTags || (context.store.getters.getUserTags.length === 0) ) {
+ let myTagsResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/userTags');
if (!myTagsResponse || !myTagsResponse.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
@@ -105,7 +107,7 @@ export default {
let tagStreams = [];
let popularTags = [];
- let tagStreamsApiResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/tagStreams');
+ let tagStreamsApiResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tagStreams');
if (tagStreamsApiResponse && tagStreamsApiResponse.data && tagStreamsApiResponse.data.data) {
tagStreams = tagStreamsApiResponse.data.data.featured_tags ? tagStreamsApiResponse.data.data.featured_tags : [];
popularTags = tagStreamsApiResponse.data.data.popular_tags ? tagStreamsApiResponse.data.data.popular_tags : [];
diff --git a/pages/search/index.vue b/pages/search/index.vue
index d00b2eb..5fa140d 100644
--- a/pages/search/index.vue
+++ b/pages/search/index.vue
@@ -10,6 +10,7 @@
<script>
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
@@ -23,7 +24,8 @@ export default {
},
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/searchForPostsWithEmptyReactions?q=' + this.getMySearchQuery;
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/searchForPostsWithEmptyReactions?q=' + this.getMySearchQuery;
} else {
return '/me/searchForPostsWithMyReactions?q=' + this.getMySearchQuery;
}
@@ -69,7 +71,8 @@ export default {
context.store.dispatch('resetPostFeed');
let searchQuery = (context.route.query && context.route.query.q) ? context.route.query.q : '';
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/searchForPostsWithEmptyReactions?q=' + searchQuery, 'selection': 'alltime'} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/searchForPostsWithEmptyReactions?q=' + searchQuery, 'selection': 'alltime'} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/searchForPostsWithMyReactions?q=' + searchQuery, 'selection': 'alltime'} );
}
diff --git a/pages/tag/_id.vue b/pages/tag/_id.vue
index c649554..805e56c 100644
--- a/pages/tag/_id.vue
+++ b/pages/tag/_id.vue
@@ -73,6 +73,7 @@ import FollowPeopleWidget from "@/components/UserFollowPeople/FollowPeopleWidget
import dummyDataTagStreamsJson from '@/assets/js/dummyData/tagStreams.json';
import dummyDataTagDetailsJson from '@/assets/js/dummyData/tagDetails.json';
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
scrollToTop: true,
@@ -120,8 +121,9 @@ export default {
//console.log('asyncData has executed!', 'server=', process.server, 'client=', process.client);
try {
// get data for current tag
+ const runtimeConfig = useRuntimeConfig();
let currentTagSlug = context.params.id;
- let currentTagResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/tags/' + currentTagSlug);
+ let currentTagResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tags/' + currentTagSlug);
let currentTag = null;
if (currentTagResponse && currentTagResponse.data && currentTagResponse.data.data) {
currentTag = currentTagResponse.data.data;
diff --git a/pages/tag/_id/index.vue b/pages/tag/_id/index.vue
index 449e92f..dcaba2a 100644
--- a/pages/tag/_id/index.vue
+++ b/pages/tag/_id/index.vue
@@ -9,6 +9,7 @@
<script>
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
@@ -24,7 +25,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
} else {
return '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
}
@@ -39,7 +41,8 @@ export default {
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'feed'} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'feed'} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'feed'} );
}
diff --git a/pages/tag/_id/latest.vue b/pages/tag/_id/latest.vue
index 9c2d4b4..d75ba5f 100644
--- a/pages/tag/_id/latest.vue
+++ b/pages/tag/_id/latest.vue
@@ -9,6 +9,7 @@
<script>
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
@@ -24,7 +25,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
} else {
return '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
}
@@ -43,7 +45,8 @@ export default {
// See https://wildermuth.com/2019/04/22/Vuex-and-Asynchronicity
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'latest'} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'latest'} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': 'latest'} );
}
diff --git a/pages/tag/_id/top/_slug.vue b/pages/tag/_id/top/_slug.vue
index f49f218..97883b1 100644
--- a/pages/tag/_id/top/_slug.vue
+++ b/pages/tag/_id/top/_slug.vue
@@ -10,6 +10,7 @@
<script>
import myGlobalConstants from '@/plugins/myGlobalConstants';
import NewsFeed from "@/components/NewsFeed/NewsFeed.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
NewsFeed,
@@ -34,7 +35,8 @@ export default {
computed: {
getFeedUrl() {
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
+ const runtimeConfig = useRuntimeConfig();
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
} else {
return '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + this.tagSlug;
}
@@ -71,7 +73,8 @@ export default {
context.store.dispatch('resetPostFeed');
if (!context.store.getters.isAuthenticated) {
- await context.store.dispatch('retrievePosts', {'feedUrl': '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': currentSelection} );
+ const runtimeConfig = useRuntimeConfig();
+ await context.store.dispatch('retrievePosts', {'feedUrl': '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': currentSelection} );
} else {
await context.store.dispatch('retrievePosts', {'feedUrl': '/me/getPostsWithMyReactions?dummyParam=1&tagSlugs=' + currentTagSlug, 'selection': currentSelection} );
}
diff --git a/pages/test/payments/testStripeElements.vue b/pages/test/payments/testStripeElements.vue
index eaed9e5..b17b5f2 100644
--- a/pages/test/payments/testStripeElements.vue
+++ b/pages/test/payments/testStripeElements.vue
@@ -36,10 +36,11 @@ export default {
},
components: { Card },
data () {
+ const runtimeConfig = useRuntimeConfig();
return {
isStripeLoaded: false,
complete: false,
- stripePublicKey: process.env.stripePublishableKey,
+ stripePublicKey: runtimeConfig.public.stripePublishableKey,
stripeOptions: {
// see https://stripe.com/docs/stripe.js#element-options for details
}
diff --git a/pages/test/payments/testStripePaymentsAndre.vue b/pages/test/payments/testStripePaymentsAndre.vue
index 42eb03f..1ccabbd 100644
--- a/pages/test/payments/testStripePaymentsAndre.vue
+++ b/pages/test/payments/testStripePaymentsAndre.vue
@@ -93,6 +93,7 @@ import { Card, createToken } from 'vue-stripe-elements-plus'
export default {
components: { Card },
data () {
+ const runtimeConfig = useRuntimeConfig();
return {
isStripeLoaded: false,
// csrf: document.head.querySelector('meta[name="csrf-token"]').content,
@@ -109,7 +110,7 @@ export default {
stripeTokenValue: '',
},
complete: false,
- stripePublicKey: process.env.stripePublishableKey,
+ stripePublicKey: runtimeConfig.public.stripePublishableKey,
errorMessage: '',
stripeOptions: {
// see https://stripe.com/docs/stripe.js#element-options for details
diff --git a/pages/test/payments/testViewPlans.vue b/pages/test/payments/testViewPlans.vue
index 63e10ee..5f98bf8 100644
--- a/pages/test/payments/testViewPlans.vue
+++ b/pages/test/payments/testViewPlans.vue
@@ -274,14 +274,16 @@
// import { stripeKey, stripeOptions } from './stripeConfig.json'
// import { Card, createToken } from 'vue-stripe-elements-plus'
import RotateSquare2Spinner from "@/components/partials/Spinners/RotateSquare2Spinner.vue";
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
RotateSquare2Spinner,
},
data () {
+ const runtimeConfig = useRuntimeConfig();
return {
- stripePublicKey: process.env.stripePublishableKey,
+ stripePublicKey: runtimeConfig.public.stripePublishableKey,
isStripeLoaded: false,
showCreditCardForm: false,
@@ -708,7 +710,8 @@ export default {
// Get data for all plans
let paymentPlans = [];
- let myPlansResponse = await $fetch('/' + process.env.backendPublicApiPrefix + '/plans');
+ const runtimeConfig = useRuntimeConfig();
+ let myPlansResponse = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/plans');
if (!myPlansResponse || !myPlansResponse.data) {
return context.error({ statusCode: 404, message: 'Something went wrong. The link you clicked on may be broken or no longer exist.' });
}
diff --git a/pages/test/testAjaxFetch.vue b/pages/test/testAjaxFetch.vue
index 8a8daf0..06aced2 100644
--- a/pages/test/testAjaxFetch.vue
+++ b/pages/test/testAjaxFetch.vue
@@ -32,6 +32,8 @@
</template>
<script>
+import {useRuntimeConfig} from "nuxt/app";
+
export default {
layout: "default",
@@ -50,7 +52,8 @@ export default {
/*
try {
let response = $fetch('https://dog.ceo/api/breeds/image/random');
- //let response = $fetch('/' + process.env.backendPublicApiPrefix + '/tags');
+ //const runtimeConfig = useRuntimeConfig();
+ //let response = $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tags');
console.log(response);
} catch (error) {
//console.error(error);
@@ -71,7 +74,8 @@ export default {
async testGetTags () {
try {
- const { data } = await $fetch('/' + process.env.backendPublicApiPrefix + '/tags');
+ const runtimeConfig = useRuntimeConfig();
+ const { data } = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tags');
console.log(data);
this.testGetTagsOutput = data;
} catch (e) {
diff --git a/pages/test/testAjaxInAsyncData.vue b/pages/test/testAjaxInAsyncData.vue
index f81d5e4..f3a2dcd 100644
--- a/pages/test/testAjaxInAsyncData.vue
+++ b/pages/test/testAjaxInAsyncData.vue
@@ -13,6 +13,8 @@
</template>
<script>
+import {useRuntimeConfig} from "nuxt/app";
+
export default {
layout: "default",
data() {
@@ -28,7 +30,8 @@ export default {
// See https://nuxtjs.org/guide/async-data/#using-async-await
async asyncData(context) {
let {data} = await $fetch('https://api.myjson.com/bins/qxr3r')
- //let data = await $fetch('/' + process.env.backendPublicApiPrefix + '/tags');
+ // const runtimeConfig = useRuntimeConfig();
+ // let data = await $fetch('/' + runtimeConfig.backendPublicApiPrefix + '/tags');
return {
info:data,
dude:'123',
diff --git a/pages/test/testInfiniteLoad.vue b/pages/test/testInfiniteLoad.vue
index e2d7fbd..2511878 100644
--- a/pages/test/testInfiniteLoad.vue
+++ b/pages/test/testInfiniteLoad.vue
@@ -27,6 +27,7 @@
import InfiniteLoad from "~/components/InfiniteLoader.vue";
import NewsFeedContentCard from "@/components/NewsFeed/NewsFeedContentCard.vue";
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
export default {
components: {
@@ -37,8 +38,9 @@ export default {
},
computed: {
postsUrl() {
+ const runtimeConfig = useRuntimeConfig();
if (!this.authenticated) {
- return '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions';
+ return '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions';
} else {
return '/me/getPostsWithMyReactions';
}
@@ -50,8 +52,9 @@ export default {
async asyncData(context) {
let postsApiUrl = null;
if (!context.store.getters.isAuthenticated) {
+ const runtimeConfig = useRuntimeConfig();
// get data for posts (feed), and append the empty bookmarks / reactions, since the user is not logged in
- postsApiUrl = '/' + process.env.backendPublicApiPrefix + '/getPostsWithEmptyReactions';
+ postsApiUrl = '/' + runtimeConfig.backendPublicApiPrefix + '/getPostsWithEmptyReactions';
} else {
// get data for posts (feed), and append the currently logged-in user's bookmarked posts
postsApiUrl = '/me/getPostsWithMyReactions';
diff --git a/plugins/mixins/myGlobalMixins.js b/plugins/mixins/myGlobalMixins.js
index f0a75d7..a4f20c4 100755
--- a/plugins/mixins/myGlobalMixins.js
+++ b/plugins/mixins/myGlobalMixins.js
@@ -1,4 +1,5 @@
-import Vue from 'vue'
+import Vue from 'vue';
+import {useRuntimeConfig} from "nuxt/app";
Vue.mixin({
methods: {
@@ -9,7 +10,8 @@ Vue.mixin({
this.$router.push('/login');
},
$socialLogin(service) {
- window.location.href = process.env.backendApiUrl + `/api/v1/auth/login/${service}`;
+ const runtimeConfig = useRuntimeConfig();
+ window.location.href = runtimeConfig.backendApiUrl + `/api/v1/auth/login/${service}`;
},
}
})
diff --git a/plugins/myGlobalConstants.js b/plugins/myGlobalConstants.js
index a883be6..1c8e463 100755
--- a/plugins/myGlobalConstants.js
+++ b/plugins/myGlobalConstants.js
@@ -1,4 +1,5 @@
import dayjs from 'dayjs';
+import {useRuntimeConfig} from "nuxt/app";
/* Regular Expression Constants
* Note: make sure you don't wrap regular expression constants in "" or ''. They are NOT strings.
@@ -68,7 +69,8 @@ const globalUtilityFunctions = {
sanitizeUserAndProfile(userObj) {
// profile_picture is the collection name in the media table and the field name in QAP
if (userObj && userObj.profile && userObj.profile.profile_picture && userObj.profile.profile_picture.url) {
- // userObj.profile_picture_url = process.env.backendApiUrl + userObj.profile.profile_picture.url;
+ // const runtimeConfig = useRuntimeConfig();
+ // userObj.profile_picture_url = runtimeConfig.backendApiUrl + userObj.profile.profile_picture.url;
userObj.profile_picture_url = userObj.profile.profile_picture.url;
} else {
userObj.profile_picture_url = globalUtilityFunctions.getDefaultProfilePictureUrl();
@@ -128,7 +130,8 @@ const globalUtilityFunctions = {
sanitizePost(post) {
// featured_image is the collection name in the media table and the field name in QAP
if (post.featured_image && post.featured_image.url) {
- // post.featured_image_url = process.env.backendApiUrl + post.featured_image.url;
+ // const runtimeConfig = useRuntimeConfig();
+ // post.featured_image_url = runtimeConfig.backendApiUrl + post.featured_image.url;
post.featured_image_url = post.featured_image.url;
} else {
post.featured_image_url = "";
@@ -136,7 +139,8 @@ const globalUtilityFunctions = {
// profile_picture is the collection name in the media table and the field name in QAP
if (post.user && post.user.profile && post.user.profile.profile_picture && post.user.profile.profile_picture.url) {
- // post.user.profile_picture_url = process.env.backendApiUrl + post.user.profile.profile_picture.url;
+ // const runtimeConfig = useRuntimeConfig();
+ // post.user.profile_picture_url = runtimeConfig.backendApiUrl + post.user.profile.profile_picture.url;
post.user.profile_picture_url = post.user.profile.profile_picture.url;
} else {
post.user.profile_picture_url = globalUtilityFunctions.getDefaultProfilePictureUrl();
diff --git a/store/index.js b/store/index.js
index c8992a0..3cfff36 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,9 +1,11 @@
import dayjs from 'dayjs';
import myGlobalConstants from '@/plugins/myGlobalConstants';
+import {useRuntimeConfig} from "nuxt/app";
// import Cookies from 'js-cookie'
+const runtimeConfig = useRuntimeConfig();
export const state = () => ({
- showExperimentalCode: process.env.MY_ENV_NAME == "local" && process.env.showExperimentalCode,
+ showExperimentalCode: process.env.MY_ENV_NAME === "local" && runtimeConfig.showExperimentalCode,
currentDate: null,
readingListCount: 0,