When you say that the application stopped working, can you clarify in what way it stopped? Are you seeing different error pages? Do you have any logs you could share?
You mention that you see the 404 error while trying to query a photo via Microsoft Graph. Querying https://graph.microsoft.com/v1.0/me/photo/$value will only return a photo if one exists (photo was added to the contact/added in Azure). Otherwise it will return a 404. It is also possible that the application or user does not have the correct permissions to access the photo, or you do not have the correct scopes to set. Please make sure that you have the scope permission set at least to User.Read , and check that the correct API permissions exist in the app registration.
Adding optional claims can affect the format of the token and the permissions granted to the application. If the application does not have permissions to access the resource or if the application cannot handle the new format of the token, you may see 404 errors.
Note also that for Azure AD B2C tenants, retrieving a user's photo using Microsoft Graph is not supported.