I assume that modifying the codebase of the app is out of discussion but yeah, that's the best approach. If you know that the second input field will be always the second one, you can use
cy.get('.div').eq(1)
that gets a DOM element at a specific index in an array of elements