Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

node.js - 立即部署单独的api和ui | 节点js(deploy seperate api and ui with NOW | nodejs)

I'm not sure if what I want is possible, I haven't found anything that says it could be done.

(我不确定我想要的东西是否可能实现,我还没有发现任何可以实现的目标。)

Mostly I "think" it should be possible.

(通常,我“认为”这应该是可能的。)

The thing is: I have a seperate file for my api and user interface, and would love to deploy both using zeit-now for now (see file struct below, hope it's clear).

(问题是:我的api和用户界面有一个单独的文件,并且现在希望使用zeit-now部署这两个文件(请参阅下面的文件结构,希望很清楚)。)

Now the main question is, is it possible to deploy both api.js and server.js using zeit-now?

(现在的主要问题是,是否可以使用zeit-now部署api.js和server.js?)

Kind regards, Daneel

(亲切的问候,Daneel)

root
|-api
|--api.js
|-ui
|--server.js
  ask by A-Daneel translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Unless you specify your own custom routes in your now.json file, anything in the root api folder will be treated by Zeit as both serverless functions and the core of your project.

(除非您在now.json文件中指定自己的自定义路由 ,否则Zeit会将api根文件夹中的所有内容都视为无服务器功能和项目的核心。)

Your best bet is to deploy two separate projects within Zeit — your frontend (which should be a static-build JAMstack-style site) and your backend, which is comprised of serverless functions, to which your frontend app makes API calls.

(最好的选择是在Zeit中部署两个单独的项目-前端(应该是静态构建的JAMstack风格的站点)和后端(由无服务器功能组成),前端应用程序向其调用API。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...