-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxt bridge is not adding the head metadata into the initial loading HTML file. #20
Comments
same here |
I'm also having this issue attempting to upgrade from nuxt 2 to nuxt bridge. Are there any known work arounds for now? EDIT: #27 (comment) appears to fix this for now. |
Is there a known way to inject the Edit: Edit0:
but it throws the error Using it like in the bridge docs also doesn't work. It seems that I need to add a hook outside of the nuxtJS framework to add the needed Edit1: hooks: {
generate: {
done(generator) {
let extraFilePath = path.join(generator.distPath, 'index.html')
fs.writeFileSync(
extraFilePath,
fs
.readFileSync(extraFilePath)
.toLocaleString()
.replace(
'<head>',
`<head>
<title>Title</title>
<meta data-n-head="1" charset="utf-8">
<meta data-n-head="1" content="width=device-width,initial-scale=1" name="viewport">
<meta data-n-head="1" content="" data-hid="description" name="description">
<meta data-n-head="1" content="telephone=no" name="format-detection">
<link data-n-head="1" href="/favicon.ico" rel="icon" type="image/x-icon">`
)
)
extraFilePath = path.join(generator.distPath, '200.html')
fs.writeFileSync(
extraFilePath,
fs
.readFileSync(extraFilePath)
.toLocaleString()
.replace(
'<head>',
`<head>
<title>Title</title>
<meta data-n-head="1" charset="utf-8">
<meta data-n-head="1" content="width=device-width,initial-scale=1" name="viewport">
<meta data-n-head="1" content="" data-hid="description" name="description">
<meta data-n-head="1" content="telephone=no" name="format-detection">
<link data-n-head="1" href="/favicon.ico" rel="icon" type="image/x-icon">`
)
)
},
},
}, But it's still broken, if I access a url path directly instead via the router. Edit2: <!-- TODO WORKAROUND FOR https://github.com/nuxt/bridge/issues/20
REMOVE FILE AFTER FIXED!-->
<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
<head {{ HEAD_ATTRS }}>
{{ HEAD }}
<title>Title</title>
<meta data-n-head="1" charset="utf-8">
<meta data-n-head="1" content="width=device-width,initial-scale=1" name="viewport">
<meta data-n-head="1" content="" data-hid="description" name="description">
<meta data-n-head="1" content="telephone=no" name="format-detection">
<link data-n-head="1" href="/favicon.ico" rel="icon" type="image/x-icon">
</head>
<body {{ BODY_ATTRS }}>
{{ APP }}
</body>
</html> |
This does not appear to be occurring in the latest version. |
Signed-off-by: Martin Dünkelmann <[email protected]>
Hey @wattanx, bug still happens within the latest version when using Ouput when using <!DOCTYPE html>
<html >
<head >
<link rel="modulepreload" as="script" crossorigin href="/_nuxt/1b8a5db.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/2b79740.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/7ce7b7d.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/d7f6c67.js"><link rel="prefetch" as="script" crossorigin href="/_nuxt/1fa85a8.js">
</head>
<body >
<div id="__nuxt"></div><script>window.__NUXT__=(function(a,b){return {serverRendered:false,config:{public:{},app:{baseURL:a,basePath:a,assetsPath:b,cdnURL:"",buildAssetsDir:b}}}}("\u002F","\u002F_nuxt\u002F"))</script><script type="module" src="/_nuxt/1b8a5db.js" crossorigin></script><script type="module" src="/_nuxt/2b79740.js" crossorigin></script><script type="module" src="/_nuxt/7ce7b7d.js" crossorigin></script><script type="module" src="/_nuxt/d7f6c67.js" crossorigin></script>
</body>
</html> With <!DOCTYPE html>
<html >
<head >
<title>Nuxt.js starter for CSB</title><meta data-n-head="ssr" charset="utf-8"><meta data-n-head="ssr" name="viewport" content="width=device-width, initial-scale=1"><meta data-n-head="ssr" data-hid="description" name="description" content="Official Nuxt.js starter for CodeSandBox"><link data-n-head="ssr" rel="icon" type="image/x-icon" href="/favicon.ico"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/5452fdc.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/ae4ca0a.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/bc5cfe3.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/d7f6c67.js"><link rel="modulepreload" as="script" crossorigin href="/_nuxt/1fa85a8.js"><style data-vue-ssr-id="38b0ce29:0">.nuxt-progress{background-color:#000;height:2px;left:0;opacity:1;position:fixed;right:0;top:0;transition:width .1s,opacity .4s;width:0;z-index:999999}.nuxt-progress.nuxt-progress-notransition{transition:none}.nuxt-progress-failed{background-color:red}</style>
</head>
<body >
<div data-server-rendered="true" id="__nuxt"><!----><div id="__layout"><div></div></div></div><script>window.__NUXT__=(function(a,b){return {layout:"default",data:[{}],fetch:{},error:null,serverRendered:true,routePath:a,config:{public:{},app:{baseURL:a,basePath:a,assetsPath:b,cdnURL:"",buildAssetsDir:b}},_asyncData:{},_errors:{}}}("\u002F","\u002F_nuxt\u002F"))</script><script type="module" src="/_nuxt/5452fdc.js" crossorigin></script><script type="module" src="/_nuxt/ae4ca0a.js" crossorigin></script><script type="module" src="/_nuxt/bc5cfe3.js" crossorigin></script><script type="module" src="/_nuxt/d7f6c67.js" crossorigin></script>
</body>
</html> Using Versions: Nuxt: both "nuxt": "^2.17.0" and "nuxt-edge 2.17.1-28131860.8edc36e" |
Environment
Nuxt CLI v3.0.0-27460146.2ad93eb
RootDir: /projects/nuxt
Nuxt project info:
Darwin
v16.14.2
2.16.0-27358576.777a4b7f
[email protected]
webpack
telemetry
,ssr
,bridge
,head
,env
,loading
,css
,plugins
,router
,modules
,axios
,build
,buildModules
,server
@nuxtjs/[email protected]
,@nuxtjs/[email protected]
,@nuxtjs/[email protected]
@nuxtjs/[email protected]
,@nuxt/[email protected]
Reproduction
Updated package.json as follows:
"nuxt": "^2.14.12", -> "nuxt-edge": "latest",
+"@nuxt/bridge": "npm:@nuxt/bridge-edge@^3.0.0-27460146.2ad93eb",
+"@nuxt/devalue": "^2.0.0",
+"std-env": "^3.0.1", -- added because of #175
"dev": "nuxi dev",
npm run dev
Describe the bug
Nuxt bridge is not adding the head metadata into the initial loading HTML file.
Following is config after upgrade:
After using bridge

Before using bridge

Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: