<p>I have WSO2 API Manager 4.0.0 running on kubernetes. I need to be able to configure CORS on the oauth2 endpoint. Following the documentation I've tried <a href="https://is.docs.wso2.com/en/latest/learn/cors/#cors" rel="nofollow noreferrer">this one</a> and <a href="https://is.docs.wso2.com/en/5.10.0/administer/invoking-an-endpoint-from-a-different-domain/#applying-cors-filter-to-another-web-application" rel="nofollow noreferrer">this other one</a>.</p>
<p>When I use the second one outside a container it works. In kubernetes I've tried to mount a ConfigMap with <code>web.xml</code> in <code>wso2-config-volume/repository/deployment/server/webapps/oauth2/WEB-INF/</code></p>
<p>I've also tried mounting it in <code>${WSO2_SERVER_HOME}/repository/deployment/server/webapps/oauth2/WEB-INF/</code></p>
<p>Both cause the following error on startup.</p>
<pre><code>[/oauth2] Servlet [OAuth2Endpoints] in web application [/oauth2] threw load() exception
java.lang.ClassNotFoundException: org.apache.cxf.transport.servlet.CXFServlet
</code></pre>
<p>I thought that there was a problem with the oauth2.war deployment if the file web.xml already existed so I created a container with the oauth2 folder already created and a web.xml already configured. However, it gets overwritten. Finally, I tried to delete the oauth2.war so that the file won't be overwritten. The oauth2 webapp won't work, it returns 404 errors.</p>
<p>Is there any way to configure CORS for the oauth2 endpoints while running on kubernetes?</p>

josecu08
<p>Can you try the following in your dockerfile?</p>
<pre><code>ARG WSO2_SERVER_NAME=wso2am
ARG WSO2_SERVER_VERSION=4.0.0
ARG USER=wso2carbon
ARG USER_HOME=/home/${USER}
ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION}
ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
ARG WEB_APP_DIR=${WSO2_SERVER_HOME}/repository/deployment/server/webapps

COPY oauth2-web.xml ${WSO2_SERVER_HOME}/
RUN mkdir ${WEB_APP_DIR}/oauth2 \
    &amp;&amp; unzip -q ${WEB_APP_DIR}/oauth2.war -d ${WEB_APP_DIR}/oauth2 \
    &amp;&amp; cp ${WSO2_SERVER_HOME}/oauth2-web.xml ${WEB_APP_DIR}/oauth2/WEB-INF/web.xml \
    &amp;&amp; rm ${WEB_APP_DIR}/oauth2.war \
    &amp;&amp; rm ${WSO2_SERVER_HOME}/oauth2-web.xml \
    &amp;&amp; chown wso2carbon:wso2 -R ${WEB_APP_DIR}/oauth2
</code></pre>
