Skip to content

Commit c762413

Browse files
committed
auto reload
1 parent e4da809 commit c762413

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

bin/dev-with-frontend

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export RACK_ENV=${RACK_ENV:-development}
1515
echo "Starting html2rss-web development environment..."
1616
echo "Environment: $RACK_ENV"
1717
echo "Ruby server: http://localhost:3000"
18-
echo "Astro dev server: http://localhost:4321"
18+
echo "Astro dev server: http://localhost:4321 (with live reload)"
19+
echo "Main development URL: http://localhost:4321"
1920
echo ""
2021

2122
# Function to cleanup background processes
@@ -24,8 +25,10 @@ cleanup() {
2425
echo "Shutting down servers..."
2526
kill $RUBY_PID 2>/dev/null || true
2627
kill $ASTRO_PID 2>/dev/null || true
28+
kill $WATCHER_PID 2>/dev/null || true
2729
wait $RUBY_PID 2>/dev/null || true
2830
wait $ASTRO_PID 2>/dev/null || true
31+
wait $WATCHER_PID 2>/dev/null || true
2932
echo "Servers stopped."
3033
exit 0
3134
}
@@ -41,9 +44,11 @@ RUBY_PID=$!
4144
# Wait a moment for Ruby server to start
4245
sleep 3
4346

44-
# Start Astro dev server
45-
echo "Starting Astro dev server..."
47+
# Start Astro dev server with API proxy
48+
echo "Starting Astro dev server with API proxy..."
4649
cd frontend
50+
51+
# Start Astro dev server (it will proxy API calls to Ruby server)
4752
npm run dev &
4853
ASTRO_PID=$!
4954

frontend/astro.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ export default defineConfig({
1111
watch: {
1212
usePolling: true,
1313
},
14+
proxy: {
15+
'/api': {
16+
target: 'http://localhost:3000',
17+
changeOrigin: true,
18+
},
19+
'/auto_source': {
20+
target: 'http://localhost:3000',
21+
changeOrigin: true,
22+
},
23+
'/health_check.txt': {
24+
target: 'http://localhost:3000',
25+
changeOrigin: true,
26+
},
27+
},
1428
},
1529
},
1630
})

frontend/src/pages/auto-source.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ import Layout from "../layouts/Layout.astro"
9999
try {
100100
// Encode URL for API
101101
const encodedUrl = btoa(url)
102-
const apiUrl = `http://localhost:3000/auto_source/${encodedUrl}?strategy=${strategy}`
102+
const apiUrl = `/auto_source/${encodedUrl}?strategy=${strategy}`
103103

104104
// Show result area
105105
const resultArea = document.getElementById("result")

frontend/src/pages/gallery.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Layout from "../layouts/Layout.astro"
44
// Fetch available feeds from API
55
let feeds = []
66
try {
7-
const baseUrl = Astro.url.origin
8-
const response = await fetch(`${baseUrl}/api/feeds.json`)
7+
const response = await fetch('/api/feeds.json')
98
if (response.ok) {
109
feeds = await response.json()
1110
}

frontend/src/pages/index.astro

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import Layout from "../layouts/Layout.astro"
44
// Fetch available feeds from Ruby backend
55
let feeds = []
66
try {
7-
const backendUrl = "http://localhost:3000"
8-
const response = await fetch(`${backendUrl}/api/feeds.json`)
7+
const response = await fetch('/api/feeds.json')
98
if (response.ok) {
109
feeds = await response.json()
1110
}
@@ -18,7 +17,7 @@ try {
1817
<div class="hero">
1918
<h2>Convert websites to RSS feeds</h2>
2019
<p>Transform any website into a structured RSS feed instantly</p>
21-
<a href="http://localhost:3000/api/example" class="btn" aria-describedby="example-desc"
20+
<a href="/api/example" class="btn" aria-describedby="example-desc"
2221
>Try Example Feed</a
2322
>
2423
<p id="example-desc" class="sr-only">Opens the example RSS feed in a new tab</p>
@@ -49,11 +48,11 @@ try {
4948
<div class="feed-item" role="listitem">
5049
<h4>{feed.name}</h4>
5150
<p>{feed.description}</p>
52-
<a
53-
href={`http://localhost:3000${feed.url}`}
54-
class="feed-link"
55-
aria-label={`Subscribe to ${feed.name} RSS feed`}
56-
>
51+
<a
52+
href={feed.url}
53+
class="feed-link"
54+
aria-label={`Subscribe to ${feed.name} RSS feed`}
55+
>
5756
Subscribe
5857
</a>
5958
</div>

0 commit comments

Comments
 (0)