Closed timkrins closed 8 months ago
After a little fun doing a manual bisect... just my luck - a bug in Next.JS 13.0.4 - bumping to 13.0.5 produces correctly minified code... I now realise that this is actually a very old version of NextJS... It was fixed in the next v13.0.5-canary.3 release, likely by the newer swc_core version.
Lesson learned: bump dependencies before spending hours debugging!
Hello,
Firstly, thanks @ganigeorgiev, this project is fantastic and you truly have the patience of a saint.
This is not a problem with this library, but just a heads up for anyone else experiencing a strange issue where relative URLs are being used in your PocketBase requests instead of absolute URLs, even when a fully-defined URL is given as the
baseUrl
.I was using Next.JS 13.0.4 and PocketBase 0.20.3.
I have traced my issue to minification of the
buildUrl
function. See original https://github.com/pocketbase/js-sdk/blob/efb5b67a67347c529f51d9ac8a614e4210ac9868/src/Client.ts#L265In the PocketBase
dist
files, thebuildUrl
function is transpiled with this as the result: (prettified for readability)But, after going through the build process with Next.JS and
swc
minification, it ends up like this:They are very similar, except for the last few lines. The minified result for some reason does not append to
t
(the minifiedurl
variable in the original source), but overwrites it, which means that the URL will never include the value originally inthis.baseUrl
.Switching off minification in
next.config.js
fixed my issue. I am going to try and investigate exactly why, but I hope that others might find this useful.