Capacitor plugin to bypass CORS & same origin policy for iframes.
npm install capacitor-plugin-xframeCapacitor plugin to bypass CORS & same origin policy for iframe.
> This plugin overrides the shouldInterceptRequest behavior of your webview.
As the core purpose of this plugin, shouldInterceptRequest needs to be leveraged to determine the outgoing requests and eliminate the __X-Frame-Options__ and __Content-Security-Policy__ headers present on the incoming responses for them to work in the embeded iframes.
* Android
``bash`
npm install capacitor-plugin-xframe
npx cap sync
Add these options in either capacitor.config.json or capacitor.config.ts.
Customize the outgoing requests' User-Agent header. Useful to modify the resulted responses.
`json`
{
...
"plugins": {
"Xframe": {
"userAgent": "
}
}
}
A list of domains/URLs to ignore from intercepting.
`json`
{
...
"plugins": {
"Xframe": {
"ignore": ["google.com", "https://www.facebook.com"]
}
}
}
* register()
* addListener('onLoad', ...)
* addListener('onError', ...)
* Interfaces
* Type Aliases
`typescript`
register() => Promise
Registers the plugin to your app.
Registering this plugin will override the shouldInterceptRequest behavior of your webview.
--------------------
`typescript`
addListener(eventName: 'onLoad', listener: LoadEventListener) => Promise
Listens to requests of document type and returns some useful information.
| Param | Type |
| --------------- | --------------------------------------------------------------- |
| eventName | 'onLoad' |
| listener | LoadEventListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
`typescript`
addListener(eventName: 'onError', listener: ErrorEventListener) => Promise
Listens to failed requests (of any type)
| Param | Type |
| --------------- | ----------------------------------------------------------------- |
| eventName | 'onError' |
| listener | ErrorEventListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
--------------------
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
#### LoadEventData
| Prop | Type |
| ------------- | ------------------- |
| url | string |
| title | string |
| favicon | string |
#### ErrorEventData
| Prop | Type |
| ---------------- | ------------------- |
| url | string |
| statusCode | number |
| message` | string |
#### LoadEventListener
(eventData: LoadEventData): void
#### ErrorEventListener
(eventData: ErrorEventData): void