Skip to content

Commit c997799

Browse files
committed
fix: some url issues
1 parent ec50632 commit c997799

File tree

8 files changed

+17
-12
lines changed

8 files changed

+17
-12
lines changed

.env.example

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
PORT=8000
2-
ORIGIN=http://localhost
1+
APP_PORT=8000
2+
APP_URL=http://localhost:8000
3+
CLIENT_URL=http://localhost:3000
34

45
MONGODB_URI=mongodb+srv://user:[email protected]/example
56

src/@types/global.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export declare global {
77

88
namespace NodeJS {
99
interface ProcessEnv {
10-
PORT: number
11-
ORIGIN: string
10+
APP_PORT: number
11+
APP_URL: string
12+
CLIENT_URL: string
1213
MONGODB_URI: string
1314
REDIS_URI: string
1415
REDIS_TOKEN_EXPIRATION: number

src/controllers/mediaController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const mediaController = {
1414
const image = await new Image(media).sharp()
1515

1616
return res.status(StatusCodes.OK).json({
17-
data: { id: media.id, image },
17+
data: { id: media.id, image: `${process.env.APP_URL}/${image}` },
1818
message: ReasonPhrases.OK,
1919
status: StatusCodes.OK
2020
})

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ app.use(
3232
notFoundMiddleware
3333
)
3434

35-
app.listen(process.env.PORT)
35+
app.listen(process.env.APP_PORT)

src/mailer/mailer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export abstract class Mailer {
2121
views: {
2222
root: joinRelativeToMainPath(process.env.MAIL_TPL_PATH),
2323
locals: {
24-
origin: process.env.ORIGIN,
24+
clientUrl: process.env.CLIENT_URL,
2525
t: i18next.t
2626
},
2727
options: { extension: 'ejs' }

src/middlewares/corsMiddleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import cors from 'cors'
22
import { StatusCodes } from 'http-status-codes'
33

44
export const corsMiddleware = cors({
5-
origin: process.env.ORIGIN,
5+
origin: process.env.CLIENT_URL,
66
optionsSuccessStatus: StatusCodes.OK
77
})

src/templates/resetPassword/html.ejs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
77
<title><%=t('resetPassword')%></title>
88
<style>
99
* {
@@ -42,7 +42,10 @@
4242
</tr>
4343
<tr>
4444
<td>
45-
<a href="<%=`${origin}/reset-password/${accessToken}`%>" target="_blank">
45+
<a
46+
href="<%=`${clientUrl}/reset-password/${accessToken}`%>"
47+
target="_blank"
48+
>
4649
<%=t('followUp')%>
4750
</a>
4851
</td>

src/templates/verification/html.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<tr>
4444
<td>
4545
<a
46-
href="<%=`${origin}/verification/${accessToken}`%>"
46+
href="<%=`${clientUrl}/verification/${accessToken}`%>"
4747
target="_blank"
4848
>
4949
<%=t('followUp')%>

0 commit comments

Comments
 (0)