Skip to content

Commit 16a876e

Browse files
committed
deploy to Render
1 parent 83af0aa commit 16a876e

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ jobs:
4141
distribution: temurin
4242
java-version: '21'
4343

44+
- name: Wait for PostgreSQL to be ready
45+
run: |
46+
until pg_isready -h localhost -p 5432 -U postgres; do
47+
echo "Waiting for postgres..."
48+
sleep 2
49+
done
50+
4451
- name: Build backend with Maven
4552
working-directory: backend
4653
run: mvn clean package
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
spring.application.name=demo
2-
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/springdemo}
1+
spring.application.name=springreactpostgres
2+
spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/springreact}
33
spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres}
44
spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:postgres}
55
spring.jpa.show-sql=true
66
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
77
spring.jpa.properties.hibernate.format_sql=true
8-
spring.jpa.hibernate.ddl-auto=create-drop
8+
spring.jpa.hibernate.ddl-auto=validate
99

1010
server.error.include-message=always

frontend/src/components/NewStudent.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function NewStudent() {
99

1010
const handleSubmit = (e) => {
1111
e.preventDefault();
12-
fetch('http://localhost:8080/student/add', {
12+
fetch('http://spring-react-backend-latest.onrender.com/student/add', {
1313
method: 'POST',
1414
headers: { 'Content-Type': 'application/json' },
1515
body: JSON.stringify(student)

frontend/src/components/Students.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ function Students() {
66
const navigate = useNavigate();
77

88
useEffect(() => {
9-
fetch('http://localhost:8080/student')
9+
fetch('http://spring-react-backend-latest.onrender.com/student')
1010
.then(res => res.json())
1111
.then(data => setStudents(data))
1212
.catch(err => console.error('Error fetching students:', err));
1313
}, []);
1414

1515
const deleteStudent = (id) => {
1616
if (!window.confirm('Are you sure you want to delete this student?')) return;
17-
fetch(`http://localhost:8080/student/delete/${id}`, { method: 'DELETE' })
17+
fetch(`http://spring-react-backend-latest.onrender.com/student/delete/${id}`, { method: 'DELETE' })
1818
.then(() => setStudents(prev => prev.filter(s => s.id !== id)))
1919
.catch(err => console.error('Delete failed:', err));
2020
};

frontend/src/components/UpdateStudent.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function UpdateStudent() {
77
const navigate = useNavigate();
88

99
useEffect(() => {
10-
fetch(`http://localhost:8080/student/${id}`)
10+
fetch(`http://spring-react-backend-latest.onrender.com/student/${id}`)
1111
.then(res => res.json())
1212
.then(data => {
1313
console.log("student", data);
@@ -20,7 +20,7 @@ function UpdateStudent() {
2020

2121
const handleSubmit = (e) => {
2222
e.preventDefault();
23-
fetch(`http://localhost:8080/student/update/${id}?firstName=${encodeURIComponent(student.firstName)}&lastName=${encodeURIComponent(student.lastName)}&email=${encodeURIComponent(student.email)}&dob=${encodeURIComponent(student.dob)}`, {
23+
fetch(`http://spring-react-backend-latest.onrender.com/student/update/${id}?firstName=${encodeURIComponent(student.firstName)}&lastName=${encodeURIComponent(student.lastName)}&email=${encodeURIComponent(student.email)}&dob=${encodeURIComponent(student.dob)}`, {
2424
method: 'PUT',
2525
headers: { 'Content-Type': 'application/json' },
2626
body: JSON.stringify(student) // can also be '{}' or null if your backend ignores it

0 commit comments

Comments
 (0)