Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Paolillo committed Oct 7, 2020
2 parents f63a77c + 69eb7e0 commit 5c8eb12
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# vue-xframe
Vue directive to bypass X-Frame-Options deny/sameorigin response headers
[Original project](https://github.com/niutech/x-frame-bypass)

I was looking for a way to bypass CSP X-Frame-Options policy to embed some websites into an `<iframe>` in my vue app.
Since the original library will not work in vue, I've decided to use part of the code to create this directive. Under the hood it will not do a lot.
When the website url is passed to the directive, the desired website is fetched using a proxy that will handle CORS headers.
In this way the `is` attribute problem that was causing the problem with vue is bypassed and the same result of the original library is achived in vue.

**How to use**
Import the file into your vue app entry point to register a global directive or use it inside your components.
```
import Vue from 'vue';
import App from './App';
import Xframe from 'vue-xframe';
//Global directive registration
Vue.directive('xframe', xframe);
new Vue({
el: '#app',
render: h => (App)
});
//Local directive registration
directives: {
Xframe
}
```
Then on the iframe add
```
<!-- Do not set the src / set url using prop or data -->
<iframe xframe="url" ></iframe>
```

0 comments on commit 5c8eb12

Please sign in to comment.