Capacitor plugin to bypass CORS & same origin policy for iframe.
This plugin overrides the shouldInterceptRequest behavior of your webview to intercept the outgoing requests and modifies the resulted responses by eliminating the X-Frame-Options and Content-Security-Policy headers for them to work in the embeded iframes.
- Android
npm install capacitor-plugin-xframe
npx cap syncAdd these options in either capacitor.config.json or capacitor.config.ts.
Customize the outgoing requests' User-Agent header. Useful to modify the resulted responses.
{
...
"plugins": {
"Xframe": {
"userAgent": "<your_custom_user_agent>"
}
}
}start() => Promise<void>Starts intercepting requests to modify responses and remove iframes restrictions.
stop() => Promise<void>Stops intercepting requests and restores default behavior of the WebView.
addListener(eventName: 'onLoad', listener: LoadEventListener) => Promise<PluginListenerHandle>Listens to requests of document type and returns some useful information.
| Param | Type |
|---|---|
eventName |
'onLoad' |
listener |
LoadEventListener |
Returns: Promise<PluginListenerHandle>
addListener(eventName: 'onError', listener: ErrorEventListener) => Promise<PluginListenerHandle>Listens to failed requests (of any type)
| Param | Type |
|---|---|
eventName |
'onError' |
listener |
ErrorEventListener |
Returns: Promise<PluginListenerHandle>
| Prop | Type |
|---|---|
remove |
() => Promise<void> |
| Prop | Type |
|---|---|
url |
string |
title |
string |
favicon |
string |
| Prop | Type |
|---|---|
url |
string |
statusCode |
number |
message |
string |
(eventData: LoadEventData): void
(eventData: ErrorEventData): void