-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add fields support to facebook provider
* feat: add fields support to facebook provider * fix: move server plugin to core * lint fix * chore: fix types --------- Co-authored-by: Sébastien Chopin <seb@nuxt.com>
- Loading branch information
Showing
3 changed files
with
39 additions
and
4 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,23 @@ | ||
import type { NitroApp } from 'nitropack' | ||
import { defineNitroPlugin } from 'nitropack/runtime' | ||
|
||
export default defineNitroPlugin((nitroApp: 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> | ||
`) | ||
}) | ||
} | ||
}) |