Can I use Protocol-relative URL in url-prefix?

like. “//example.com/dist/

Nothing will stop you, but this isn’t what you want. It’s intended to be an absolute url.

what if the CDN sever provide both http and https. I am not sure which protocol will be use in webpages. How can I set url-prefix proper ?

I’d argue you shouldn’t do that and only access over https. Then use https in your url-prefix.