Files
twenty/front/src/modules/users/utils/getProfilePictureAbsoluteURI.ts
Ruslan a5fe256d7e chore: inject enviroment at the ./front deployment phase (#2174) (#2179)
* chore: inject enviroment at the deployment phase (#2174)

* Dockerfile CMD env.sh
* env.sh generates env-config.js file
* index.html imports env-config.js
* front/src/config/index.ts imports REACT_APP_SERVER_BASE_URL

* Upgrade Dockerfiles

* Add compute pg_database_url for render

* fix tests

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
2023-10-22 12:36:36 +02:00

21 lines
444 B
TypeScript

import { REACT_APP_SERVER_BASE_URL } from '~/config';
export const getImageAbsoluteURIOrBase64 = (imageUrl?: string | null) => {
if (!imageUrl) {
return null;
}
if (imageUrl?.startsWith('data:')) {
return imageUrl;
}
if (imageUrl?.startsWith('https:')) {
return imageUrl;
}
const serverFilesUrl =
REACT_APP_SERVER_BASE_URL ?? REACT_APP_SERVER_BASE_URL + '/files';
return `${serverFilesUrl}/${imageUrl}`;
};