Add to cart button not working for products with configurable options
I've got an issue with a site where any items with configurable options are unable to be added to the cart. The Add to Cart button does not validate and cannot be clicked.
Chrome developer tools shows a couple of errors.
GET https://my.site/static/version1668254510/frontend/Magento/luma/en_US/mage/validation/validation.js net::ERR_ABORTED 404
Refused to execute script from 'https://my.site/static/version1668254510/frontend/Magento/luma/en_US/mage/validation/validation.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
Error: Script error for: mage/validation/validation http://requirejs.org/docs/errors.html#scripterror at makeError (require.js:166:17) at HTMLScriptElement.onScriptError (require.js:1681:36)
I think the second one holds all the answers but I am unsure what to do to fix it. I've confirmed the version number is the same as the value in the deployed_version.txt file. As far as I can tell, everything else is working correctly. Backend works fine.
I've tried deleting all files from the static folder (except .htaccess). I've tried it without the .htaccess file. I've redeployed the contact numerous times. I've restarted the apache service and the server.
In my static folder I have a validation.js file at this location
This does not have the additional validation subfolder shown in the error message. This file opens in Chrome with no problem. I tried adding a folder called validation and copying the validation.js file into that folder but this didn't work.
If I click on the link in developer tools to open the js file I get this error page
Unable to resolve the source file for 'frontend/Magento/luma/en_US/mage/validation/validation.js'
<pre>#1 Magento\Framework\App\StaticResource->launch() called at [vendor/magento/framework/App/Bootstrap.php:263]
#2 Magento\Framework\App\Bootstrap->run() called at [pub/static.php:13]
I'm a bit stuck and would prefer to find a fix than roll back to an earlier backup.
Re: Add to cart button not working for products with configurable options
Update: My earlier information was incorrect. Creating the validation folder and copying the validation.js file has got the site working again. This is not fixed but is a bandaid solution. I have deleted the file and created a symlink and will keep trying to work out what has gone wrong.