Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d51286a

Browse files
committed
prepend app env vars with NEXT_PUBLIC_
1 parent c95b84e commit d51286a

File tree

99 files changed

+179
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+179
-321
lines changed

book/1-end/app/next.config.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
// eslint-disable-next-line
2-
require('dotenv').config();
3-
41
module.exports = {
5-
env: {
6-
URL_APP: process.env.URL_APP,
7-
URL_API: process.env.URL_API,
8-
PORT_APP: process.env.PORT_APP,
9-
},
2+
poweredByHeader: false,
3+
webpack5: true,
104
};

book/1-end/app/pages/_document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from 'react';
33

44
class MyDocument extends Document {
55
public render() {
6-
console.log(process.env.URL_APP);
6+
console.log(process.env.NEXT_PUBLIC_URL_APP);
77
return (
88
<Html lang="en">
99
<Head>

book/10-begin/app/components/common/LoginButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LoginButton extends React.PureComponent<Props, State> {
1919
public render() {
2020
const { invitationToken } = this.props;
2121

22-
let url = `${process.env.URL_API}/auth/google`;
22+
let url = `${process.env.NEXT_PUBLIC_URL_API}/auth/google`;
2323
const qs = makeQueryString({ invitationToken });
2424

2525
if (qs) {

book/10-begin/app/components/discussions/CreateDiscussionForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class CreateDiscussionForm extends React.Component<Props, State> {
239239

240240
await discussion.sendDataToLambda({
241241
discussionName: discussion.name,
242-
discussionLink: `${process.env.URL_APP}/team/${discussion.team.slug}/discussions/${discussion.slug}`,
242+
discussionLink: `${process.env.NEXT_PUBLIC_URL_APP}/team/${discussion.team.slug}/discussions/${discussion.slug}`,
243243
postContent: post.content,
244244
authorName: post.user.displayName,
245245
userIds: userIdsForLambda,

book/10-begin/app/components/discussions/DiscussionActionMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class DiscussionActionMenu extends React.Component<Props, State> {
102102
}
103103

104104
const selectedDiscussion = currentTeam.discussions.find((d) => d._id === id);
105-
const discussionUrl = `${process.env.URL_APP}/team/${currentTeam.slug}/discussions/${selectedDiscussion.slug}`;
105+
const discussionUrl = `${process.env.NEXT_PUBLIC_URL_APP}/team/${currentTeam.slug}/discussions/${selectedDiscussion.slug}`;
106106

107107
try {
108108
if (window.navigator) {

book/10-begin/app/components/layout/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ function LayoutWrapper({
118118
},
119119
{
120120
text: 'Log out',
121-
href: `${process.env.URL_API}/logout`,
122-
as: `${process.env.URL_API}/logout`,
121+
href: `${process.env.NEXT_PUBLIC_URL_API}/logout`,
122+
as: `${process.env.NEXT_PUBLIC_URL_API}/logout`,
123123
externalServer: true,
124124
},
125125
]}
@@ -170,8 +170,6 @@ class Layout extends React.Component<Props> {
170170

171171
const { currentUser, currentTeam } = store;
172172

173-
const isThemeDark = currentUser && currentUser.darkTheme === true;
174-
175173
// console.log(this.props.store.currentUser.darkTheme);
176174

177175
// const isThemeDark = false;

book/10-begin/app/components/posts/PostForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class PostForm extends React.Component<Props, State> {
182182

183183
await discussion.sendDataToLambda({
184184
discussionName: discussion.name,
185-
discussionLink: `${process.env.URL_APP}/team/${discussion.team.slug}/discussions/${discussion.slug}`,
185+
discussionLink: `${process.env.NEXT_PUBLIC_URL_APP}/team/${discussion.team.slug}/discussions/${discussion.slug}`,
186186
postContent: post.content,
187187
authorName: post.user.displayName,
188188
userIds: userIdsForLambda,

book/10-begin/app/lib/api/sendRequestAndGetResponse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export default async function sendRequestAndGetResponse(path, opts: any = {}) {
2323

2424
const qs = (opts.qs && `?${makeQueryString(opts.qs)}`) || '';
2525

26-
// console.log(`before: ${process.env.URL_API}${path}${qs}`);
26+
// console.log(`before: ${process.env.NEXT_PUBLIC_URL_API}${path}${qs}`);
2727

2828
const response = await fetch(
29-
opts.externalServer ? `${path}${qs}` : `${process.env.URL_API}${path}${qs}`,
29+
opts.externalServer ? `${path}${qs}` : `${process.env.NEXT_PUBLIC_URL_API}${path}${qs}`,
3030
Object.assign({ method: 'POST', credentials: 'include' }, opts, { headers }),
3131
);
3232

33-
// console.log(`after: ${process.env.URL_API}${path}${qs}`);
33+
// console.log(`after: ${process.env.NEXT_PUBLIC_URL_API}${path}${qs}`);
3434

3535
// console.log(response.status);
3636
// console.log(response.statusText);

book/10-begin/app/lib/api/team-member.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export const deletePostApiMethod = (data) =>
9292
});
9393

9494
export const sendDataToLambdaApiMethod = (data) =>
95-
sendRequestAndGetResponse(`${process.env.API_GATEWAY_ENDPOINT}/`, {
95+
sendRequestAndGetResponse(`${process.env.NEXT_PUBLIC_API_GATEWAY_ENDPOINT}/`, {
9696
externalServer: true,
9797
body: JSON.stringify(data),
9898
});

book/10-begin/app/lib/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function initializeStore(initialState = {}) {
146146

147147
const socket = isServer
148148
? null
149-
: io(process.env.URL_API, {
149+
: io(process.env.NEXT_PUBLIC_URL_API, {
150150
reconnection: true,
151151
autoConnect: true,
152152
transports: ['polling', 'websocket'],

0 commit comments

Comments
 (0)