Failed to install app: Request Entity Too Large for Custom App

Dear house,

I am trying to upload a custom App through the App Management custom import. I got the error Failed to install app: Request Entity Too Large.

Where can I edit the setting to allow for bigger size because my app is not as bit as some I have seen in the hub.

@rithvik @Gassim

@jetisco4u ,

You got this error in the UI or in the tomcat logs? I tried to search the code base but couldn’t find the error that says “Request Entity Too Large”. May I know the size of file you are uploading?

Thanks,
Rithvik

@jetisco4u this is usually a setting in either the nginx gateway or tomcat web server you are running, I don’t believe there is any limit enforced by DHIS2 itself. This depends on how your server is configured. You can look at, for example, the client_max_body_size setting in nginx.conf or one of these settings in Tomcat

1 Like

@rithvik about 12mb

@austin I will look into the Nginx configuration. By the way I checked and I am not using nginx in the local environment

1 Like

@austin @rithvik I managed to reduce the size and it seems to be passing. But then I keep getting the error Failed to load resource: the server responded with a status of 409 (). I have tried to follow the best principles from app-platform. I have tried to keep the app simple but don’t know what is throwing the error and there are no further clue to debug.

When I inspect the console, I saw the error pointing to this line in api.js }) => fetch(`${this.baseUrl}/api/${url}`,

@jetisco4u ,

When are you getting this error? When you upload the app or when you are loading your custom application? If it’s your custom app, how are you resolving this.baseUrl ?

Thanks,
Rithvik

@rithvik when I upload my custom app. I am not setting any value for baseUrl. I thought the system will pick it since I am using the app-platform. Do I need to set it up and where should I do that? I didn’t see any reference to it in the repo except for when uploading to the app hub which I am not.

@jetisco4u ,

One way to resolve this is using the dhis2 app-runtime.

Using the useConfig hook ,you can get the base url.
Other way would be using relative paths in the API requests.

Thanks,
Rithvik

@rithvik where am I supposed to set the baseUrl in the custom App. I do not see anywhere in the system to do that.

@jetisco4u ,
My bad, I assumed you are getting this error when you are loading your app (I assumed the error was from your code). As now you mentioned, it is when you are uploading the app from app manager, I’m not sure on the root cause.

Thanks,
Rithvik

Hello @austin and @rithvik I am back to the error on Failed to install app: Request Entity Too Large.. I didn’t try your suggested solution then because I just reduce the size of the app and it was working. Now I have a live instance of DHIS2 running on a domain. I have a basic custom app built using the app platform. I have uploaded it with no issue in the localhost instance. But when I tried to do same in the live server instance, I get the error above. I checked the client_max_body_size in nginx.conf and it is set at 10m. Shouldn’t that be enough to upload an app of 1.59mb?

EDITED
I set the client_max_body_size to 200M as per @austing advice. When I tried again, the error didn’t show but I run into the baseUrl error.