The cloudfront.net URL indicates you have asset optimization enabled. You can disable this via the UI under Site settings > Build & deploy > Post processing > Asset optimization.
As for why the resource paths have {{ pathto(\" _static="" scripts="" pydata-sphinx-theme.js\',="" 1)="" }} appended I cannot say for certain, but I suspect this is either part of your templating, or part of the NextJS plugin.
But I still don’t know why resource path have {{ pathto(\" _static="" scripts="" pydata-sphinx-theme.js\',="" 1)="" }} when asset optimization is enabled.