mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
27 lines
463 B
TypeScript
27 lines
463 B
TypeScript
import type CspDev from 'csp-dev';
|
|
|
|
import config from 'configs/app';
|
|
|
|
const feature = config.features.addressProfileAPI;
|
|
|
|
export function usernameApi(): CspDev.DirectiveDescriptor {
|
|
if (!feature.isEnabled) {
|
|
return {};
|
|
}
|
|
|
|
const apiOrigin = (() => {
|
|
try {
|
|
const url = new URL(feature.apiUrlTemplate);
|
|
return url.origin;
|
|
} catch (error) {
|
|
return '';
|
|
}
|
|
})();
|
|
|
|
return {
|
|
'connect-src': [
|
|
apiOrigin,
|
|
],
|
|
};
|
|
}
|