-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { defineNitroPlugin } from '#imports' | ||
|
||
export default defineNitroPlugin((nitroApp) => { | ||
if (process.env.NUXT_OAUTH_FACEBOOK_CLIENT_ID && process.env.NUXT_OAUTH_FACEBOOK_CLIENT_SECRET) { | ||
// In facebook login, the url is redirected to /#_=_ which is not a valid route | ||
// so we remove it from the url, we are loading this long before the app is loaded | ||
// by using render:html hook | ||
// this is a hack, but it works | ||
// https://stackoverflow.com/questions/7131909/facebook-callback-appends-to-return-url | ||
nitroApp.hooks.hook('render:html', (html) => { | ||
html.head.unshift(` | ||
<script> | ||
if (window.location.hash === "#_=_"){ | ||
history.replaceState | ||
? history.replaceState(null, null, window.location.href.split("#")[0]) | ||
: window.location.hash = ""; | ||
} | ||
</script> | ||
`) | ||
}) | ||
} | ||
}) |