Skip to content

Masked urls with environment variables #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"entryFile": "backend/src/main.js"
}
2 changes: 0 additions & 2 deletions backend/src/notifications/notification.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { Notification } from '../../../middle-layer/types/Notification';
@Controller('notifications')
export class NotificationController {


constructor(private readonly notificationService: NotificationService) { }


// allows to create a new notification
@Post()
async create(@Body() notification: Partial<Notification>): Promise<Notification> {
Expand Down
2 changes: 1 addition & 1 deletion backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": "../",
"rootDirs": ["./src", "../middle-layer"],
"module": "commonjs",
"target": "es2017",
"experimentalDecorators": true,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Bell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const BellButton = () => {
// function that handles when button is clicked and fetches notifications
const handleClick = async () => {
const response = await fetch(
`http://localhost:3001/notifications/user/${currUserID}`,
`${import.meta.env.VITE_SERVER_URL}/notifications/user/${currUserID}`,
{
method: "GET",
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Profile = observer(() => {
e.preventDefault();

try {
const response = await fetch("http://localhost:3001/auth/update-profile", {
const response = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/update-profile", {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Register = observer(() => {
e.preventDefault();

try {
const response = await fetch("http://localhost:3001/auth/register", {
const response = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password, email }),
Expand All @@ -30,7 +30,7 @@ const Register = observer(() => {
}

// If registration succeeded, automatically log in the user
const loginResponse = await fetch("http://localhost:3001/auth/login", {
const loginResponse = await fetch(import.meta.env.VITE_SERVER_URL+"/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ username, password }),
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/context/auth/authContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const AuthProvider = observer(({ children }: { children: ReactNode }) =>
* Attempt to log in the user
*/
const login = async (username: string, password: string) => {
const response = await fetch('http://localhost:3001/auth/login', {
const response = await fetch(import.meta.env.VITE_SERVER_URL+'/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password }),
Expand All @@ -54,7 +54,7 @@ export const AuthProvider = observer(({ children }: { children: ReactNode }) =>
* Register a new user and automatically log them in
*/
const register = async (username: string, password: string, email: string) => {
const response = await fetch('http://localhost:3001/auth/register', {
const response = await fetch(import.meta.env.VITE_SERVER_URL+'/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, email }),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/grant-info/components/GrantItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const GrantItem: React.FC<GrantItemProps> = ({ grant }) => {
try {
console.log("Saving grant!");
console.log(curGrant);
const response = await fetch("http://localhost:3001/grant/save", {
const response = await fetch(import.meta.env.VITE_SERVER_URL+"/grant/save", {
method: "PUT",
headers: {
"Content-Type": "application/json",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/grant-info/components/GrantLabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const GrantLabels: React.FC<{
}

return (
<ul className="grant-labels grid grid-cols-4 justify-stretch font-semibold p-4">
<ul className="grant-labels grid grid-cols-4 justify-stretch font-semibold pt-4">
<li className="text-center">
<button
className="grant-name"
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/grant-info/components/GrantList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { Grant } from "../../../../middle-layer/types/Grant.ts";
// How many items to show per page
const fetchGrants = async () => {
try {
const response = await fetch("http://localhost:3001/grant");
const response = await fetch(import.meta.env.VITE_SERVER_URL + "/grant");
if (!response.ok) {
throw new Error(`HTTP Error, Status: ${response.status}`);
}
Expand Down Expand Up @@ -104,13 +104,14 @@ const GrantList: React.FC = observer(() => {
*/}
<PaginationRoot defaultPage={1} count={totalPages}>
{/* Actual grants for the current page */}
<div className="bg-light-orange rounded-[1.2rem] pt-2">
<GrantLabels onSort={HandleHeaderClick} />
<div className="grant-list p-4">
<div className="grant-list p-4 ">
{grants.map(grant => (
<GrantItem key={grant.grantId} grant={grant} />
))}
</div>

</div>
{/*
Paging Controls:
- Prev / Next triggers
Expand Down