add "baseUrl" for iframe in <WebView> | React Native

263 Views Asked by At

I am challenging with my own React Native browser, in that i want to inject my javascript code to iframes in page to discover Resource Timing API. With Main Frame everything is good but with iframes i got "Blocked" by not Same-Origin.

I resolved this by fetch it & add to iframe by srcdoc or access from local file. Some site is running but others are not because it has relative url in its resourses (Ex : image, js, css...). I also try html prop & local file for main frame with baseUrl prop & run ok, but with iframe whether there is anything as baseUrl ?

1

There are 1 best solutions below

2
On

I think,

The same origin is security check for the site you are trying to access, and it can only be accessed by domain that the site is from, using iframe the origin will be your domain and child site will always block this as requesting domain is different.

If you still want to use the sites which throws same origin error you might need to whitelist your domain at there site first.