Skip to content

Commit

Permalink
Merge pull request #35 from terrestris/fix-cors
Browse files Browse the repository at this point in the history
fix: avoid multiple adding of cors filter
  • Loading branch information
buehner authored Oct 6, 2021
2 parents bbf705d + f754b66 commit 95bf624
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ fi
# configure CORS (inspired by https://github.com/oscarfonts/docker-geoserver)
# if enabled, this will add the filter definitions
# to the end of the web.xml
# (this will only happen if our filter has not yet been added before)
if [ "${CORS_ENABLED}" = "true" ]; then
if ! grep -q DockerGeoServerCorsFilter "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml"; then
sed -i "\:</web-app>:i\\
<filter>\n\
<filter-name>CorsFilter</filter-name>\n\
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>\n\
<init-param>\n\
<param-name>cors.allowed.origins</param-name>\n\
Expand All @@ -39,9 +41,10 @@ if [ "${CORS_ENABLED}" = "true" ]; then
</init-param>\n\
</filter>\n\
<filter-mapping>\n\
<filter-name>CorsFilter</filter-name>\n\
<filter-name>DockerGeoServerCorsFilter</filter-name>\n\
<url-pattern>/*</url-pattern>\n\
</filter-mapping>" "$CATALINA_HOME/webapps/geoserver/WEB-INF/web.xml";
fi
fi

# start the tomcat
Expand Down

0 comments on commit 95bf624

Please sign in to comment.