I found a suggestion that led me to solve the problem with this function which requires creating an empty file named, file.to.add.to.web.app, and adding that file to the compiled web app.
function tf = iswebdeployed()
% tf = iswebdeployed()
% tests whether an app is running as a web app
% must include a file named file.to.add.to.web.app when compiling a web app
% tf = isdeployed && exist('file.to.add.to.web.app', "file");
tf = isdeployed && exist('file.to.add.to.web.app', "file");
end