My code is working in Preview but not on published site.

I have put a code and that is working properly in preview but is not working on Live website. Please anyone help.
My code:

import wixLocation from ‘wix-location’ ;

// Navigation
const nextPage = () => {
wixLocation . to ( “/home-1” );
};

$w . onReady ( function () {
const button = $w ( ‘#Enterbutton’ );
const focusTrap = $w ( ‘#input1’ );

button . onClick (() => {
nextPage ();
});

focusTrap . onKeyPress (( event ) => {
if ( event . key === ‘Enter’ ) {
nextPage ();
}
});

// Focus trap.
// If user click somewhere then we return the focus to input
focusTrap . onBlur (() => {
setTimeout (() => {
focusTrap . focus ();
}, 100 );
});

focusTrap . focus ();
});

Check your DATABASE-PERMISSIONs first.
Who is allowed to enter your DB ?

Second check → Sync your Preview and Live-DB.