fix: set base URL to '/' and add comprehensive tests - #1393
Conversation
- Fixed vite.config.ts to default base URL to '/' instead of '' - Added unit tests (vite.config.test.ts) to verify base URL configuration - Added E2E tests (tests/baseUrl.spec.ts) to verify assets load from root path This ensures assets are loaded from /assets/ instead of /profile/assets/ when navigating to nested routes like /profile/:id. Fixes #329 Co-authored-by: Aviv <AvivAbachi@users.noreply.github.com>
|
@claude |
|
Claude finished @AvivAbachi's task in 1m 11s —— View job Analysis of preview environment issue
Issue IdentifiedI found the problem! The preview deployment needs an update because:
SolutionThe build workflow needs to set - name: Build
env:
ASSET_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.run_number }}/
run: npm run buildThis way:
Note: I cannot modify workflow files in |
|
@claude see this output:
PASS src/pages/components/utils/index.test.ts Test Suites: 2 passed, 2 total |
|
Claude finished @NoamGaash's task in 1m 38s —— View job Fixed test error ✓
Root CauseThe error
SolutionRemoved
This eliminates the Jest/Vitest conflict while maintaining test coverage through the E2E tests. Branch: claude/issue-329-20260105-1935 |
Removed the unit test for vite.config.ts because: - It was causing a conflict between Jest and Vitest matchers - The E2E tests in baseUrl.spec.ts already verify the base URL behavior comprehensively - Unit testing a build config with mocks is fragile and provides limited value compared to E2E tests Co-authored-by: Noam Gaash <NoamGaash@users.noreply.github.com>
…asadna/open-bus-map-search into claude/issue-329-20260105-1935
|
@claude can you fix all the commect |
|
Claude finished @AvivAbachi's task in 1m 28s —— View job Fixed review comments ✓
SummaryAdded
These assertions guarantee that the tests are actually checking meaningful data rather than passing vacuously when no assets are found. Branch: claude/issue-329-20260105-1935 | |
Add expect(array.length).toBeGreaterThan(0) checks to ensure tests are actually verifying meaningful data. Co-authored-by: Aviv <AvivAbachi@users.noreply.github.com>
|
@claude unable to load page on preview server https://s3.amazonaws.com/noam-gaash.co.il/20776238780/open-bus/1489/index.html {
"log": {
"version": "1.2",
"creator": {
"name": "WebInspector",
"version": "537.36"
},
"pages": [
{
"startedDateTime": "2026-01-07T09:04:22.678Z",
"id": "page_1",
"title": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html",
"pageTimings": {
"onContentLoad": 353.3980000001975,
"onLoad": 386.4770000000135
}
}
],
"entries": [
{
"_connectionId": "36644",
"_initiator": {
"type": "other"
},
"_priority": "VeryHigh",
"_resourceType": "document",
"cache": {},
"connection": "443",
"pageref": "page_1",
"request": {
"method": "GET",
"url": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br, zstd"
},
{
"name": "Accept-Language",
"value": "en-IL,en-GB;q=0.9,en-US;q=0.8,en;q=0.7"
},
{
"name": "Cache-Control",
"value": "max-age=0"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Host",
"value": "s3.amazonaws.com"
},
{
"name": "If-Modified-Since",
"value": "Mon, 05 Jan 2026 20:21:25 GMT"
},
{
"name": "If-None-Match",
"value": "\"8c2fc8cc909ac7160fc8cf9633a5fc7b\""
},
{
"name": "Referer",
"value": "https://github.com/hasadna/open-bus-map-search/pull/1393"
},
{
"name": "Sec-Fetch-Dest",
"value": "document"
},
{
"name": "Sec-Fetch-Mode",
"value": "navigate"
},
{
"name": "Sec-Fetch-Site",
"value": "cross-site"
},
{
"name": "Sec-Fetch-User",
"value": "?1"
},
{
"name": "Upgrade-Insecure-Requests",
"value": "1"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
},
{
"name": "sec-ch-ua",
"value": "\"Google Chrome\";v=\"143\", \"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\""
},
{
"name": "sec-ch-ua-mobile",
"value": "?0"
},
{
"name": "sec-ch-ua-platform",
"value": "\"Windows\""
}
],
"queryString": [],
"cookies": [],
"headersSize": 941,
"bodySize": 0
},
"response": {
"status": 304,
"statusText": "Not Modified",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Wed, 07 Jan 2026 09:04:27 GMT"
},
{
"name": "ETag",
"value": "\"8c2fc8cc909ac7160fc8cf9633a5fc7b\""
},
{
"name": "Last-Modified",
"value": "Mon, 05 Jan 2026 20:21:25 GMT"
},
{
"name": "Server",
"value": "AmazonS3"
},
{
"name": "x-amz-expiration",
"value": "expiry-date=\"Tue, 13 Jan 2026 00:00:00 GMT\", rule-id=\"delete old things\""
},
{
"name": "x-amz-id-2",
"value": "zBEvvXbu0z8yh5WSlhlTOiDgkUB7ovOVcL1DHJpgffg30kJ1RH/42FLVPicEDSoZ6umafPDggIZ0KY5cxKgn/gtbXlZIsmu3"
},
{
"name": "x-amz-request-id",
"value": "QBCZE71N211WC1N1"
}
],
"cookies": [],
"content": {
"size": 3251,
"mimeType": "text/html"
},
"redirectURL": "",
"headersSize": 410,
"bodySize": 0,
"_transferSize": 410,
"_error": null,
"_fetchedViaServiceWorker": false
},
"serverIPAddress": "16.15.186.81",
"startedDateTime": "2026-01-07T09:04:22.677Z",
"time": 160.99300000041694,
"timings": {
"blocked": 2.0639999999761347,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.08399999999999985,
"wait": 158.2510000003489,
"receive": 0.5940000000919099,
"_blocked_queueing": 0.8649999999761349,
"_workerStart": -1,
"_workerReady": -1,
"_workerFetchStart": -1,
"_workerRespondWithSettled": -1
}
},
{
"_connectionId": "36644",
"_initiator": {
"type": "parser",
"url": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html",
"lineNumber": 70
},
"_priority": "High",
"_resourceType": "script",
"cache": {},
"connection": "443",
"pageref": "page_1",
"request": {
"method": "GET",
"url": "https://s3.amazonaws.com/assets/index-DeOHyd6r.js",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "*/*"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br, zstd"
},
{
"name": "Accept-Language",
"value": "en-IL,en-GB;q=0.9,en-US;q=0.8,en;q=0.7"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Host",
"value": "s3.amazonaws.com"
},
{
"name": "Origin",
"value": "https://s3.amazonaws.com"
},
{
"name": "Referer",
"value": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html"
},
{
"name": "Sec-Fetch-Dest",
"value": "script"
},
{
"name": "Sec-Fetch-Mode",
"value": "cors"
},
{
"name": "Sec-Fetch-Site",
"value": "same-origin"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
},
{
"name": "sec-ch-ua",
"value": "\"Google Chrome\";v=\"143\", \"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\""
},
{
"name": "sec-ch-ua-mobile",
"value": "?0"
},
{
"name": "sec-ch-ua-platform",
"value": "\"Windows\""
}
],
"queryString": [],
"cookies": [],
"headersSize": 654,
"bodySize": 0
},
"response": {
"status": 403,
"statusText": "Forbidden",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Content-Type",
"value": "application/xml"
},
{
"name": "Date",
"value": "Wed, 07 Jan 2026 09:04:26 GMT"
},
{
"name": "Server",
"value": "AmazonS3"
},
{
"name": "Transfer-Encoding",
"value": "chunked"
},
{
"name": "x-amz-id-2",
"value": "i76JsBH8C68s8h++FMppc8cpYi012Jf1PsSxhbDlT75smzDNLWSvidHzBIkz2v4AOSeL0seYkSjPC2z1ptHxh0DAxO/sXSEP"
},
{
"name": "x-amz-request-id",
"value": "QBCG52Z9P2JG2K1T"
}
],
"cookies": [],
"content": {
"size": 0,
"mimeType": "application/xml",
"compression": 0
},
"redirectURL": "",
"headersSize": 286,
"bodySize": 0,
"_transferSize": 286,
"_error": "net::ERR_ABORTED",
"_fetchedViaServiceWorker": false
},
"serverIPAddress": "16.15.186.81",
"startedDateTime": "2026-01-07T09:04:22.843Z",
"time": 172.96400000032008,
"timings": {
"blocked": 20.934999999608785,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.08000000000000007,
"wait": 151.01500000011356,
"receive": 0.9340000005977345,
"_blocked_queueing": 14.293999999608786,
"_workerStart": -1,
"_workerReady": -1,
"_workerFetchStart": -1,
"_workerRespondWithSettled": -1
}
},
{
"_connectionId": "36689",
"_initiator": {
"type": "parser",
"url": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html",
"lineNumber": 71
},
"_priority": "VeryHigh",
"_resourceType": "stylesheet",
"cache": {},
"connection": "443",
"pageref": "page_1",
"request": {
"method": "GET",
"url": "https://s3.amazonaws.com/assets/index-BfYS2xC2.css",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "text/css,*/*;q=0.1"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, br, zstd"
},
{
"name": "Accept-Language",
"value": "en-IL,en-GB;q=0.9,en-US;q=0.8,en;q=0.7"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Host",
"value": "s3.amazonaws.com"
},
{
"name": "Origin",
"value": "https://s3.amazonaws.com"
},
{
"name": "Referer",
"value": "https://s3.amazonaws.com/noam-gaash.co.il/20728029946/open-bus/1485/index.html"
},
{
"name": "Sec-Fetch-Dest",
"value": "style"
},
{
"name": "Sec-Fetch-Mode",
"value": "cors"
},
{
"name": "Sec-Fetch-Site",
"value": "same-origin"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36"
},
{
"name": "sec-ch-ua",
"value": "\"Google Chrome\";v=\"143\", \"Chromium\";v=\"143\", \"Not A(Brand\";v=\"24\""
},
{
"name": "sec-ch-ua-mobile",
"value": "?0"
},
{
"name": "sec-ch-ua-platform",
"value": "\"Windows\""
}
],
"queryString": [],
"cookies": [],
"headersSize": 669,
"bodySize": 0
},
"response": {
"status": 403,
"statusText": "Forbidden",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Content-Type",
"value": "application/xml"
},
{
"name": "Date",
"value": "Wed, 07 Jan 2026 09:04:26 GMT"
},
{
"name": "Server",
"value": "AmazonS3"
},
{
"name": "Transfer-Encoding",
"value": "chunked"
},
{
"name": "x-amz-id-2",
"value": "qHO0OrKMdJnokkQclaLpFVH2xjztfDfmIWCDX2aon2pxsegRnmqR8metF8LhMFC7JF0NAdSfWcuKm20Of+txfQH39JW488zA"
},
{
"name": "x-amz-request-id",
"value": "QBCRH00DF4AYGARA"
}
],
"cookies": [],
"content": {
"size": 0,
"mimeType": "application/xml",
"compression": 0
},
"redirectURL": "",
"headersSize": 286,
"bodySize": 0,
"_transferSize": 286,
"_error": "net::ERR_ABORTED",
"_fetchedViaServiceWorker": false
},
"serverIPAddress": "16.15.186.81",
"startedDateTime": "2026-01-07T09:04:22.844Z",
"time": 187.75099999947997,
"timings": {
"blocked": 22.181999999781603,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.07900000000000063,
"wait": 164.07100000043883,
"receive": 1.4189999992595403,
"_blocked_queueing": 18.052999999781605,
"_workerStart": -1,
"_workerReady": -1,
"_workerFetchStart": -1,
"_workerRespondWithSettled": -1
}
}
]
}
} |
|
Claude finished @AvivAbachi's task in 1m 1s —— View job Preview deployment issue analyzed ✓
Root CauseThe HAR data shows assets are failing with 403 Forbidden errors:
The Problem:
SolutionThe - name: Build
env:
ASSET_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.run_number }}/
run: npm run buildThis will make Why I Can't Fix ThisI'm unable to modify files in Alternative Workaround (if workflow can't be modified)If modifying the workflow is not possible, you could update export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
base: process.env.ASSET_URL || env?.ASSET_URL || '/',
// ... rest of configThis would check Branch: claude/issue-329-20260105-1935 | View job |
|
@claude this is still not working maybe in to have fix in react-route? |
|
Claude finished @AvivAbachi's task in 1m 14s —— View job Analysis Complete ✓
The IssueReact Router's Two Different Concepts:
Root Cause: Looking at base: env?.PREVIEW_URL || '/',And PREVIEW_URL: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.run_id }}/open-bus/${{ github.run_number }}/The problem: Vite's When Vite sees a full URL in <script src="https://s3.amazonaws.com/.../assets/index-DeOHyd6r.js"></script>But your HAR log shows it's actually requesting: This happens because Vite treats the URL as a path, leading to malformed asset URLs. The SolutionOption 1: Use relative path for preview (Recommended) Change base: './', // Always use relative pathsThis makes all asset paths relative ( Option 2: Extract path from PREVIEW_URL If you need different bases for production vs preview: base: env?.PREVIEW_URL
? new URL(env.PREVIEW_URL).pathname
: '/',This extracts just the path part ( Why React Router's basename won't helpSetting Branch: claude/issue-329-20260105-1935 | |
|
is working now but there is problem on preview server is cut the url how is needed to be - https://s3.amazonaws.com/noam-gaash.co.il/20777620048/open-bus/1493/storybook/index.html |
|
Claude finished @AvivAbachi's task in 1m 52s —— View job Fixed Storybook preview URL ✓
Changes MadeUpdated viteFinal: async (config) => {
// Set base URL from environment variable for preview deployments
config.base = process.env.VITE_PREVIEW_URL
? `${process.env.VITE_PREVIEW_URL}storybook/`
: '/storybook/'
return config
}This ensures:
Workflow File LimitationI was unable to push the required change to The workflow needs this manual update at line 47: - name: Build Storybook
env:
VITE_PREVIEW_URL: ${{ env.VITE_PREVIEW_URL }}
run: npm run build-storybook -- -o dist/storybookThis passes the Without this workflow change, the Storybook config won't have access to the preview URL and will fall back to Branch: claude/issue-329-20260105-1935 | |
Add viteFinal hook to .storybook/main.ts to set base URL from VITE_PREVIEW_URL environment variable for preview deployments. Co-authored-by: Aviv <AvivAbachi@users.noreply.github.com>
NoamGaash
left a comment
There was a problem hiding this comment.
Cool!
Just making sure - we don't use the outputs of the build workflow for the docker image version, right?
Docker build takes form validate.yaml > "Docker Build" if i not wrong |
|
i cheak whit local docker no problems, lets hop for the bests. update: work on live |
This PR fixes the base URL configuration issue where assets were loaded from incorrect paths when navigating to nested routes like
/profile/:id.Changes
base: env?.ASSET_URL || ''tobase: env?.ASSET_URL || '/'vite.config.test.tsto verify base URL configuration logictests/baseUrl.spec.tsto verify assets load correctly from root pathProblem
When
ASSET_URLwas not defined, the base was set to an empty string, causing Vite to use relative paths. When navigating to/profile/8235701, the browser tried to load assets from/profile/assets/...instead of/assets/....Solution
By defaulting to
'/', assets are always loaded from the root path, while still allowing customization via theASSET_URLenvironment variable for CDN deployments.Fixes #329
Generated with Claude Code