mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
fix(app): normalize url in .env (#607)
This commit is contained in:
parent
e8c4615803
commit
e375553b3f
@ -1,5 +1,5 @@
|
|||||||
VITE_OPEN_COLLECTIVE_API_KEY=your_key
|
VITE_OPEN_COLLECTIVE_API_KEY=your_key
|
||||||
VITE_API_URL=http://localhost:8055/
|
VITE_API_URL=http://localhost:8055
|
||||||
#VITE_API_URL=https://api.utopia-lab.org/
|
#VITE_API_URL=https://api.utopia-lab.org/
|
||||||
VITE_MAP_URL=http://local.development
|
VITE_MAP_URL=http://local.development
|
||||||
#VITE_MAP_URL=CURRENT_WINDOW_LOCATION
|
#VITE_MAP_URL=CURRENT_WINDOW_LOCATION
|
||||||
|
|||||||
@ -142,7 +142,7 @@ function App() {
|
|||||||
path: '/' + l.name, // url
|
path: '/' + l.name, // url
|
||||||
icon: l.markerIcon?.image ? (
|
icon: l.markerIcon?.image ? (
|
||||||
<SVG
|
<SVG
|
||||||
src={`${config.apiUrl}assets/${l.markerIcon.image_outline ?? l.markerIcon.image}`}
|
src={`${config.apiUrl}/assets/${l.markerIcon.image_outline ?? l.markerIcon.image}`}
|
||||||
style={{
|
style={{
|
||||||
width: `${(l.markerIcon.size ?? 18) * 1.3}px`,
|
width: `${(l.markerIcon.size ?? 18) * 1.3}px`,
|
||||||
height: `${(l.markerIcon.size ?? 18) * 1.3}px`,
|
height: `${(l.markerIcon.size ?? 18) * 1.3}px`,
|
||||||
@ -183,7 +183,7 @@ function App() {
|
|||||||
link.rel = 'icon'
|
link.rel = 'icon'
|
||||||
document.getElementsByTagName('head')[0].appendChild(link)
|
document.getElementsByTagName('head')[0].appendChild(link)
|
||||||
}
|
}
|
||||||
link.href = map?.logo && config.apiUrl + 'assets/' + map.logo // Specify the path to your favicon
|
link.href = map?.logo && config.apiUrl + '/assets/' + map.logo // Specify the path to your favicon
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only set loading to false when both map and layers are successfully loaded
|
// Only set loading to false when both map and layers are successfully loaded
|
||||||
@ -200,7 +200,7 @@ function App() {
|
|||||||
<div className='App tw:overflow-x-hidden'>
|
<div className='App tw:overflow-x-hidden'>
|
||||||
<AuthProvider userApi={userApi} inviteApi={inviteApi}>
|
<AuthProvider userApi={userApi} inviteApi={inviteApi}>
|
||||||
<AppShell
|
<AppShell
|
||||||
assetsApi={new assetsApi(config.apiUrl + 'assets/')}
|
assetsApi={new assetsApi(config.apiUrl + '/assets/')}
|
||||||
appName={map.name}
|
appName={map.name}
|
||||||
embedded={embedded}
|
embedded={embedded}
|
||||||
openCollectiveApiKey={config.openCollectiveApiKey}
|
openCollectiveApiKey={config.openCollectiveApiKey}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export function Welcome1({ clickAction1, map }: ChapterProps) {
|
|||||||
<h3 className='tw:font-bold tw:text-lg'>Welcome to {map?.name || 'Utopia Map'}</h3>
|
<h3 className='tw:font-bold tw:text-lg'>Welcome to {map?.name || 'Utopia Map'}</h3>
|
||||||
<img
|
<img
|
||||||
className='tw:float-right tw:w-32 tw:m-2'
|
className='tw:float-right tw:w-32 tw:m-2'
|
||||||
src={config.apiUrl + 'assets/' + map.logo}
|
src={config.apiUrl + '/assets/' + map.logo}
|
||||||
></img>
|
></img>
|
||||||
<p className='tw:py-3'>
|
<p className='tw:py-3'>
|
||||||
It is a tool for collaborative mapping to connect local initiatives, people and events.
|
It is a tool for collaborative mapping to connect local initiatives, people and events.
|
||||||
|
|||||||
@ -1,6 +1,14 @@
|
|||||||
|
const normalizeBaseUrl = (value: string) => value.replace(/\/+$/, '')
|
||||||
|
|
||||||
|
const getMapUrl = () => {
|
||||||
|
const url = String(import.meta.env.VITE_MAP_URL ?? 'http://local.development')
|
||||||
|
if (url === 'CURRENT_WINDOW_LOCATION') return url
|
||||||
|
return normalizeBaseUrl(url)
|
||||||
|
}
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
apiUrl: String(import.meta.env.VITE_API_URL ?? 'http://localhost:8055/'),
|
apiUrl: normalizeBaseUrl(String(import.meta.env.VITE_API_URL ?? 'http://localhost:8055/')),
|
||||||
mapUrl: String(import.meta.env.VITE_MAP_URL ?? 'http://local.development'),
|
mapUrl: getMapUrl(),
|
||||||
adminRole: String(import.meta.env.VITE_DIRECTUS_ADMIN_ROLE ?? ''),
|
adminRole: String(import.meta.env.VITE_DIRECTUS_ADMIN_ROLE ?? ''),
|
||||||
validateInviteFlowId: String(
|
validateInviteFlowId: String(
|
||||||
import.meta.env.VITE_VALIDATE_INVITE_FLOW_ID ?? '01d61db0-25aa-4bfa-bc24-c6a8f208a455',
|
import.meta.env.VITE_VALIDATE_INVITE_FLOW_ID ?? '01d61db0-25aa-4bfa-bc24-c6a8f208a455',
|
||||||
|
|||||||
@ -138,7 +138,7 @@ export const Landingpage = () => {
|
|||||||
<li key={idx}>
|
<li key={idx}>
|
||||||
<div className='w-24 h-24 mx-auto'>
|
<div className='w-24 h-24 mx-auto'>
|
||||||
<img
|
<img
|
||||||
src={`${config.apiUrl}assets/${item.image}`}
|
src={`${config.apiUrl}/assets/${item.image}`}
|
||||||
className='w-full h-full rounded-full'
|
className='w-full h-full rounded-full'
|
||||||
alt=''
|
alt=''
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user