<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.web>
          <httpRuntime enableVersionHeader="false"/>
        </system.web>
        <system.webServer>
        <security>
            <requestFiltering removeServerHeader="true">
                <verbs allowUnlisted="false">
                    <add verb="GET" allowed="true" />
                    <add verb="POST" allowed="true" />
                </verbs>

            </requestFiltering>
        </security>
        <httpProtocol>
            <customHeaders>
                <clear/>
                <remove name="X-Powered-By" />
                <add name="X-Frame-Options" value="SAMEORIGIN" />
                <add name="Strict-Transport-Security" value="max-age=31536000; includeSubDomains" />
                <add name="X-XSS-Protection" value="1; mode=block" />
                <add name="X-Content-Type-Options" value="nosniff" />
                <add name="Content-Security-Policy" value="default-src 'self';
                    connect-src 'self' https://*.insttantt.com https://ipwhois.pro https://ipwhois.pro/json https://ipinfo.io https://*.googleapis.com https://*.fontawesome.com wss://*.firebaseio.com wss://*.servicebus.windows.net wss://*.insttantt.com wss://*.insttantt.com/socket.io https://*.google-analytics.com https://*.ingest.sentry.io https://*.google.com/g/collect https://stats.g.doubleclick.net data: blob: https://www.google.com https://*.hotjar.com wss://*.hotjar.com https://www.googleadservices.com https://*.clarity.ms https://c.ba.contentsquare.net https://k.ba.contentsquare.net https://*.contentsquare.net https://*.hj.contentsquare.net;
                    font-src 'self' https://*.googleapis.com https://*.fontawesome.com https://*.gstatic.com https://*.hj.contentsquare.net;
                    frame-src 'self' https://*.firebaseio.com https://*.insttantt.com https://*.trustmatic.io https://www.googletagmanager.com https://td.doubleclick.net https://stripe.com https://*.stripe.com;
                    img-src 'self' https://*.insttantt.com https://*.blob.core.windows.net https://*.facebook.com https://*.facebook.com/* https://*.google.com.co/* https://picsum.photos https://fastly.picsum.photos data: blob: https://www.googleadservices.com https://www.google.com https://www.google.com.co https://*.clarity.ms https://c.bing.com https://*.ba.contentsquare.net;
                    media-src 'self';
                    object-src 'self' https://*.insttantt.com;
                    script-src 'self' 'nonce-a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6' https://*.googleapis.com https://*.seondf.com https://*.firebaseio.com https://*.fontawesome.com https://*.googletagmanager.com https://*.googletagmanager.com/gtm.js https://unpkg.com https://static.hotjar.com https://script.hotjar.com https://js.stripe.com https://*.stripe.com https://*.clarity.ms https://script.hj.contentsquare.net;
                    script-src-elem 'self' 'nonce-a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6' https://maps.googleapis.com https://*.seondf.com https://*.firebaseio.com https://*.fontawesome.com https://unpkg.com https://*.googletagmanager.com https://*.googletagmanager.com/gtm.js https://*.facebook.net https://static.hotjar.com https://script.hotjar.com https://js.stripe.com https://*.stripe.com https://*.clarity.ms https://script.hj.contentsquare.net;
                    worker-src 'self' https://*.insttantt.com data: blob:;
                    style-src 'self' 'unsafe-inline' https://*.insttantt.com https://*.googleapis.com https://*.fontawesome.com;
                    style-src-elem 'self' 'unsafe-inline' https://*.insttantt.com https://*.googleapis.com https://*.fontawesome.com;
                    frame-ancestors 'self';
                "/>

                <add name="Referrer-Policy" value="same-origin" />
                <add name="Permissions-Policy" value="geolocation=(self *)" />
            </customHeaders>
        </httpProtocol>
        <staticContent>
            <remove fileExtension="." />
            <remove fileExtension=".woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".json" mimeType="application/json" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
            <mimeMap fileExtension="." mimeType="text/plain" />
            <remove fileExtension=".cjs" />
            <mimeMap fileExtension=".cjs" mimeType="application/module+javascript" />
        </staticContent>
        <rewrite>
            <rules>
                <rule name="React Routes" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/" />
                </rule>
            </rules>
        </rewrite>
        </system.webServer>

        <!--
        Cache strategy: el bundle de CRA produce filenames con hash (main.{hash}.js, etc.).
        - index.html y manifest: no-cache para que el browser tome SIEMPRE la version nueva tras un deploy
          y referencie los nuevos hashes.
        - static/: cacheo agresivo (1 ano, immutable) porque cualquier cambio de contenido cambia el hash
          y por tanto el filename. Beneficia mucho a usuarios recurrentes.
        -->
        <location path="index.html">
            <system.webServer>
                <staticContent>
                    <clientCache cacheControlMode="DisableCache" />
                </staticContent>
                <httpProtocol>
                    <customHeaders>
                        <add name="Cache-Control" value="no-cache, no-store, must-revalidate, max-age=0" />
                        <add name="Pragma" value="no-cache" />
                        <add name="Expires" value="0" />
                    </customHeaders>
                </httpProtocol>
            </system.webServer>
        </location>

        <location path="manifest.json">
            <system.webServer>
                <staticContent>
                    <clientCache cacheControlMode="DisableCache" />
                </staticContent>
                <httpProtocol>
                    <customHeaders>
                        <add name="Cache-Control" value="no-cache, no-store, must-revalidate, max-age=0" />
                    </customHeaders>
                </httpProtocol>
            </system.webServer>
        </location>

        <location path="static">
            <system.webServer>
                <staticContent>
                    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />
                </staticContent>
                <httpProtocol>
                    <customHeaders>
                        <add name="Cache-Control" value="public, max-age=31536000, immutable" />
                    </customHeaders>
                </httpProtocol>
            </system.webServer>
        </location>
    </configuration>
