Fix dashboard 404: derive API base from page path
Opening the dashboard at /crm (no trailing slash) made the relative `api/leads` fetch resolve to /api/leads -> 404. Derive the API base from location.pathname so it works at both /crm and /crm/. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -98,7 +98,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const API = 'api';
|
// Derive the API base from this page's own path so it works whether the
|
||||||
|
// dashboard is opened at /crm or /crm/ (relative fetches break without the
|
||||||
|
// trailing slash).
|
||||||
|
const API = location.pathname.replace(/\/+$/, '') + '/api';
|
||||||
const TOKEN = '__CRM_TOKEN__';
|
const TOKEN = '__CRM_TOKEN__';
|
||||||
const COLS = {
|
const COLS = {
|
||||||
leads: ['lead_id','received_at','client_id','source','name','contact','service_interest','message','status','notified'],
|
leads: ['lead_id','received_at','client_id','source','name','contact','service_interest','message','status','notified'],
|
||||||
|
|||||||
Reference in New Issue
Block a user