Skip to content
Merged
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
17 changes: 15 additions & 2 deletions src/components/AppUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@ const AppUrl = ({path = '', children}) => {
const {
siteConfig: {customFields},
} = useDocusaurusContext();
const appUrl = customFields.appUrl || 'APP_URL';
const fullUrl = path ? `${appUrl}${path}` : appUrl;
const appUrl = customFields.appUrl;

if (!appUrl) {
console.error('APP_URL is not set in environment variables');
return <span>APP_URL</span>;
}

// Ensure the URL is absolute (starts with http:// or https://)
const baseUrl = appUrl.startsWith('http://') || appUrl.startsWith('https://')
? appUrl
: `https://${appUrl}`;

// Remove trailing slash from baseUrl if present, then add path
const cleanBaseUrl = baseUrl.replace(/\/$/, '');
const fullUrl = path ? `${cleanBaseUrl}${path}` : cleanBaseUrl;
const linkText = children || fullUrl;

return (
Expand Down