Why appears a html snippet at some js and css files endings when the client download thems?

Popincsák, Attila (SmartX) 10 Reputation points
2023-04-17T09:16:26.3366667+00:00

I have an app service in Azure. It is a java based web app which is running on a Tomcat 8.5.
In this weeks started a problem with my webapp. A html snippet appears at some js and css files endings when the client download thems. The snippet which is appended to the endings of my files during the download started with this code below:

<!DOCTYPE html><HTML><HEAD>    <TITLE>Microsoft Azure App Service - Welcome</TITLE>    <SCRIPT type="text/javascript">        function loc() {            const statusCode = 200;            const subCode = 0;            var t, h, p;            if (statusCode == 404)            {                if (subCode == 21)                {                    t = "Web App Failed to Start!";                    h = "Web App Failed to Start!";                    p = `<p>If you are the Administrator of this web app, it is likely an error occured on the application during start up, please take a look at the catalina logs to resolve the issue.                         See <a href="https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs">Enable diagnostics logging for apps in Azure App Service</a> for a guide on enabling logging.</p>`;                }                else                {                    t = "404 Page Not Found!";                    h = "404 Page Not Found!";                    p = `<p>If you are the Administrator of this web app, an error may have occured on application start up. See <a href="https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs">Enable diagnostics logging for apps in Azure App Service</a> for a guide on enabling logging.</p>`;                }            }            else if (statusCode >= 500)                    {                t = statusCode + " Web App Error!";                h = statusCode + " Web App Error!";                p =`<p>The web app has experienced an unexpected server error. We apologize for the inconvenience. Try to reload the page or visit it again soon.</p>                    <p>If you are the Administrator of this web app, see the <a href="https://go.microsoft.com/fwlink/?linkid=2095006">Azure Service Dashboard</a> for information about the status of Azure Services. Errors may also be found in application logs. See <a href="https://learn.microsoft.com/en-us/azure/app-service/troubleshoot-diagnostic-logs">Enable diagnostics logging for apps in Azure App Service</a> for a gu

You can check the result which cause the problem for me: https://test.giftcard.meta-mtps.hu/js/giftcard-validator.js?1.6.0
https://test.giftcard.meta-mtps.hu/styles/layout.css

And here are two links which is not affected: https://test.giftcard.meta-mtps.hu/js/giftcard.js?1.6.0
https://test.giftcard.meta-mtps.hu/styles/button.css Where should I search the origin of this problem? Earlier this webapp worked without any problem and whe not redeployed it before the snippet appear in my files?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2023-04-19T00:01:10.4433333+00:00

    It seems like the issue you are facing is related to the Azure App Service. The HTML snippet that is being appended to the end of your JS and CSS files is actually an error page that is being generated by the Azure App Service. This error page is being appended to the end of your files because the Azure App Service is unable to serve the requested files. The error page that is being generated by the Azure App Service suggests that there might be an issue with the startup of your web app. It is possible that the issue is related to the Tomcat 8.5 server that your web app is running on. To troubleshoot this issue, I would recommend checking the logs for your web app. You can enable diagnostics logging for your app in Azure App Service and then check the logs to see if there are any errors related to the startup of your web app. Here is a link to the Azure documentation that explains how to enable diagnostics logging for your app. Once you have enabled diagnostics logging, you can check the logs to see if there are any errors related to the startup of your web app. If you are unable to find the root cause of the issue, you can contact Azure support for further assistance.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.