Use app/tmp-index.html from instead of app/index.html for build generation based on environment variable

I am using ember version 3.4.0.
My need is to generate the build index.html file based on the environment variable type.


I have a ENV variable as isDemo

If isDemo is true => build should generated based on the public/demo-index.html.
If isDemo is false => build should generated based on the app/index.html

I have few static variables defined in public/demo-index.html which controls the action that can be performed in demo version of my app. I have set up all the process to run the demo version of app. But i want to test both the demo version and actual version of my app. For this every time before starting the server i have to replace the contents index.html file.

My need is to mimic the flow of test environment which uses the index.html file inside test folder for running test cases.

Kindly suggest me with some ideas to overcome the above problem.
Thanks in advance

Sharing the solution that solved the above need

How it’s done:

Created an in-repo addon in my app and used the serverMiddleware hook in index.js file of the addon to alter the request for the Index HTML. In serverMiddleware hook if the request comes for index.html i.e., / it will change the request url to the temp-html file which will deliver the response of the tmp-html if user request for index.html.