fix: configuration of cors

Refs: #430
This commit is contained in:
Jens Kristian Villadsen
2022-09-28 22:51:57 +02:00
parent cd1a2e1687
commit 3d03cd00c5
2 changed files with 20 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
package ca.uhn.fhir.jpa.starter.annotations;
import ca.uhn.fhir.jpa.starter.AppProperties;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
public class OnCorsPresent implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
AppProperties config = Binder.get(conditionContext.getEnvironment()).bind("hapi.fhir", AppProperties.class).orElse(null);
if (config == null) return false;
if (config.getCors() == null) return false;
return true;
}
}