I'am a newbie in cryptography, so I'm not sure, what to choose (sha256 or sha384). Sha384 is resistant to length-extension attacks, while sha256 is not. I'm not sure, which one to use.
With length extension you can create another valid value for a keyed hash, even though you don't know the key. PBKDF2 actually uses HMAC though, and that is not vulnerable to length extension attacks. The reason why you only see the hash is that HMAC has just one configuration parameter: the hash function used. PBKDF2 is not unique in this by the way, TLS also shows a hash at the end of the cipher suite name while it is actually used for a PRF.
In short, what hash to use (sha256 or sha384), when using Pbkdf2? Also, what derived key size is the best?
In principle SHA-256 can already provide 256 bit security within PBKDF2 as collision resistance is not required. However, PBKDF2 has the nasty habit of requiring the user to perform all the iterations once again for each block of 256 bit output. So if more than 256 bits are required then it makes sense to use SHA-512.
In my opinion SHA-384 doesn't make any sense for these kind of functions. Basically it is the same algorithm as SHA-512, while you then toss away bits that could provide meaningful security, or at least enables a larger output size. As already indicated, the protection against length extension is not really a problem here.
To be honest though, the whole discussion is moot. The hash function used is a configuration parameter. It is up to the implementer of the protocol to choose which hash function and iteration count to use. As provider of a PBKDF2 implementation you should enable all possible hashes - or at least SHA-1 and the SHA-2 family of hashes. If you are the sole user of your own implementation then I would suggest that the output size requirement is known, and you can select your hash based on that.
Generally you don't transmit password hashes within URL's, so I'm not sure why you are trying to use base64url. I would suggest you use an already existing scheme such as PHC, defined here for PBKDF2.