Skip to content
Merged
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
16 changes: 13 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Copy this file to .env and fill in values locally (DO NOT COMMIT .env)
# Database
DB_USER=postgres
DB_PASSWORD=changeme
# -------------------------
# DATABASE CONFIGURATION
# -------------------------
DB_USER=admin_user
DB_PASSWORD=secureBen10
DB_NAME=healthcare_auth_db

# Spring datasource (optional override)
# FOR DEPLOYMENT: Use your production database URL
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/healthcare_auth_db
SPRING_DATASOURCE_USERNAME=${DB_USER}
SPRING_DATASOURCE_PASSWORD=${DB_PASSWORD}
Expand All @@ -15,6 +18,13 @@ REDIS_PORT=6379


# Frontend API URL
# -------------------------
# CORS & FRONTEND CONFIGURATION
# -------------------------
# FOR DEPLOYMENT: Set this to your frontend URL (e.g., https://yourdomain.com)
CORS_ALLOWED_ORIGINS=http://localhost:3000,http://127.0.0.1:3000

# FOR DEPLOYMENT: Set this to your backend API URL (e.g., https://api.yourdomain.com/api)
REACT_APP_API_URL=http://localhost:8081/api

MAIL_HOST=smtp.gmail.com
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Deploy Backend

on:
push:
branches: [main]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: SSH into EC2 and deploy
uses: appleboy/ssh-action@master
with:
host: 54.252.217.169
username: ubuntu
key: ${{ secrets.EC2_SECRETKEY }}
script: |
cd ~/PatientManagementSystem
git pull origin main
docker-compose down
docker-compose up -d --build
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,15 @@ private void saveSecurityLog(String action, HttpServletRequest request) {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList(allowedOrigins.split(",")));
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("Authorization", "Content-Type"));

// Split by comma and trim whitespace
String[] origins = allowedOrigins.split(",");
configuration.setAllowedOrigins(Arrays.stream(origins).map(String::trim).toList());

configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"));
configuration.setAllowedHeaders(List.of("Authorization", "Content-Type", "X-Requested-With", "Accept", "Origin"));
configuration.setAllowCredentials(true);
configuration.setMaxAge(3600L);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
String[] origins = allowedOrigins.split(",");
registry.addMapping("/**")
.allowedOrigins(allowedOrigins.split(","))
.allowedOrigins(java.util.Arrays.stream(origins).map(String::trim).toArray(String[]::new))
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
.allowedHeaders("*")
.allowCredentials(true)
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/src/services/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// API Service - Centralized API calls for the Patient Management System
const API_BASE_URL = process.env.REACT_APP_API_URL || 'http://localhost:8081/api';
const API_BASE_URL = process.env.REACT_APP_API_URL || '';

// Helper function for API calls
const apiCall = async (endpoint, options = {}) => {
Expand Down Expand Up @@ -435,9 +435,9 @@ export const nurseAPI = {
return apiCall('/nurse/handover', { method: 'POST', body: JSON.stringify(payload) });
},
recordVitals: async (vitalSignsData) => {
return apiCall('/vital-signs', {
method: 'POST',
body: JSON.stringify(vitalSignsData)
return apiCall('/vital-signs', {
method: 'POST',
body: JSON.stringify(vitalSignsData)
});
},
recordMedicationAdministration: async (medicationData) => {
Expand Down
16 changes: 8 additions & 8 deletions frontend/app/src/services/supabaseAuth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Authentication service for backend API
const API_BASE_URL = 'http://localhost:8081/api';
const AUTH_URL = `${API_BASE_URL}/auth`;
const API_BASE_URL = process.env.REACT_APP_API_URL || '';
const AUTH_URL = API_BASE_URL ? `${API_BASE_URL}/auth` : '/auth';
const STORAGE_KEY = 'secure_health_user';
const PROFILE_STORAGE_KEY = 'secure_health_profiles';

Expand Down Expand Up @@ -301,12 +301,12 @@ export const verifyOtp = async (email, otp) => {
const resolvedEmail = email;
const storedName = getProfileName(resolvedEmail);
const fullName = data.full_name || data.fullName || storedName;
const user = {
email: resolvedEmail,
role: data.role || 'PATIENT',
fullName,
accessToken: data.accessToken,
userId: data.userId
const user = {
email: resolvedEmail,
role: data.role || 'PATIENT',
fullName,
accessToken: data.accessToken,
userId: data.userId
};
if (fullName) {
saveProfileName(resolvedEmail, fullName);
Expand Down