如何在没有 NodeJS 的情况下让我的 React 应用服务器端呈现在 APACHE 服务器上?
How to make my react app server side rendering on APACHE SERVER without NodeJS?
我 运行 我的 react
应用程序在 apache
服务器上,它是 client side rendering
。我使用 CDN 链接将 React 添加到我的网站
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js" integrity="sha256-FiZMk1zgTeujzf/+vomWZGZ9r00+xnGvOgXoj0Jo1jA=" crossorigin="anonymous"></script>
现在,我想在不使用 Nodejs
.[=16 的情况下将其转换为 server side rendering
=]
正确的做法是什么?
你不能,至少在没有大量工作的情况下不能。
要获得服务器端渲染,您需要在服务器上执行 JavaScript。 Node.js 是首屈一指的浏览器外 JavaScript 运行时,所有旨在为 React.js(如 Next.js)启用服务器端呈现的工具都旨在与 Node.js.
要使用 Apache HTTPD 和不使用 Node.js 进行服务器端呈现,您需要:
- Select 一个 JS 运行时
- 使用该运行时
实现类似于Next.js的东西
- 配置 Apache HTTP 以与该运行时通信(可能涉及编写全新的 Apache 模块)
我 运行 我的 react
应用程序在 apache
服务器上,它是 client side rendering
。我使用 CDN 链接将 React 添加到我的网站
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js" integrity="sha256-FiZMk1zgTeujzf/+vomWZGZ9r00+xnGvOgXoj0Jo1jA=" crossorigin="anonymous"></script>
现在,我想在不使用 Nodejs
.[=16 的情况下将其转换为 server side rendering
=]
正确的做法是什么?
你不能,至少在没有大量工作的情况下不能。
要获得服务器端渲染,您需要在服务器上执行 JavaScript。 Node.js 是首屈一指的浏览器外 JavaScript 运行时,所有旨在为 React.js(如 Next.js)启用服务器端呈现的工具都旨在与 Node.js.
要使用 Apache HTTPD 和不使用 Node.js 进行服务器端呈现,您需要:
- Select 一个 JS 运行时
- 使用该运行时 实现类似于Next.js的东西
- 配置 Apache HTTP 以与该运行时通信(可能涉及编写全新的 Apache 模块)