Hi Mansi Gupta
Thanks for reaching out to Microsoft Q&A forum support and apologize for the inconvenience
Based on this document: LINK ARTICLE
Any changes to custom script settings for a specific site only last for a maximum of 24 hours. After that time, the setting resets to Blocked.
This behavior is intentional and part of Microsoft’s security model for SharePoint Online. It applies to most site types, including those created via the SharePoint admin center, PowerShell, OneDrive, and modern team or communication sites.
As far as I know, to persist the setting longer, you need to use PowerShell to enable custom script at the site level. Here are the recommended commands:
Set-SPOSite <SiteURL> -DenyAddAndCustomizePages 0
or with the PnP.PowerShell cmdlet Set-PnPSite
Set-PnPSite -Identity <SiteURL> -NoScriptSite $false
Hope my answer will help you.
For any further support, kindly let us know.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.