【问题标题】:How do I use golang and nuxt?如何使用 golang 和 nuxt?
【发布时间】:2019-04-30 10:42:32
【问题描述】:

我想用 Golang 作为服务器,用 Nuxt 作为前端,我用谷歌搜索了一下,但没有找到任何例子。

我在 nuxt + express 中找到的 express/node.js 代码。链接在下面

const express = require('express')

// Create express instnace
const app = express()

// Require API routes
const users = require('./routes/users')

// Import API Routes
app.use(users)

// Export the server middleware
module.exports = {
  path: '/api',
  handler: app
}

我可以创建 golang 服务器 api 并将其部署为微服务,但我会失去 nuxt 的 SSR 功能吗?如果我使用单独的服务器而不是 nuxt + node.js 的单片版本,谷歌仍然会抓取我的网页

链接:https://github.com/nuxt-community/express-template

问候

【问题讨论】:

    标签: go vue.js nuxt.js


    【解决方案1】:

    你应该把它们分开。一台服务器用于您在 golang 中的后端 api。其他服务器是 nuxt ssr 的节点服务器。然后,您可以使用 nginx 根据路径或任何内容将请求路由到所需的服务器。一切都会好起来的

    【讨论】:

    • 你能展示一个基本的例子吗?我知道很多,但我真的需要理解,因为之前没有人展示过任何例子
    • @sinusGob 我真的不明白你想要什么的例子。你有正常的 nuxt 设置和正常的 golang 服务器。两台不同的服务器。
    猜你喜欢
    • 1970-01-01
    • 2022-10-15
    • 2019-09-19
    • 2023-01-22
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 2023-03-16
    • 1970-01-01
    相关资源
    最近更新 更多