It turned out to be some strange behavior caused by running on localhost. After uploading to the development server, everything worked