GetViewport().Size
should be the right one if you want the size of the client rect of the game window in pixels. If it's still not the case in HTML export, that might be a bug.
Otherwise if you want this in terms of game world coordinates (which might not map exactly pixels on the monitor, if you used a stretch mode), you could place two nodes as rectangle anchors in your scene and determine the random position between them. This way it should guarantee a correct position because it's inside the same world you spawn nodes, and won't be dependent on screen, pixels, stretch, zoom etc. You can also use a ReferenceRect
node to do this.