I have a Razor page that calls a script file to execute a script and that script makes a call to an API to validate email address. Recently I have made few changes to the script and added CSRF token to the call to API. We deployed the changes to the Dev server and it works fine but when we are promoting changes to UAT server, that script doesn't execute. When I use F12 dev tool to debug the issue I see the register.js file that contains the script is not loading with the page. Before making current changes, everything was working fine in all environments and script file was loading without any issue.
I have verified that the file does deploy properly on UAT server and does exist there. Folder structures are same on all servers and as I mentioned everything was working before making the current changes.
Register.js
` $.validator.addMethod("exists", function (value, element, params) {
var valid = true; var token = $('input[name=__RequestVerificationToken]').val(); var headers = { "__RequestVerificationToken": token }; $.ajax({ url: '/api/SMC/SmcRegister/UserExists?email=' + value, type: "post", async: false, headers: { "__RequestVerificationToken": headers }, data: { __RequestVerificationToken: token}, success: function (exists) { valid = exists.toLowerCase() === 'false'; $(element).data('msg-exists', $(element).data('msg-exists').replace('{0}', value)); } }); return valid; }, $.validator.format("The email {0} already exists!"));`
Page on UAT which is not loading Register.js
Same page on Dev server loading the page and script file fine