为什么React应用在AppEngine服务器上未加载JS捆绑包?

huangapple go评论107阅读模式
英文:

why react application is not loading js bundle in appengine server

问题

在本地和AWS上运行良好的React应用,在使用以下命令部署到Google App Engine时,会打开一个包含index.html内容的白色新网站;在页面源代码中如下所示:

<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
    <base href="/" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google" value="notranslate">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="manifest" href="manifest.webapp" />
    <link rel="stylesheet" href="static/css/loading.css">
</head>
<body>
    <div id="root"/>    
</body>
</html>

但不会加载js捆绑包。我在浏览器和服务器日志中找不到任何线索。

英文:

React app which works great in local and aws. But in Google App Engine, when deployed using

mvn appengine:deploy 

opens white fresh website which contains the index.html content inside; in the page source like:

&lt;!doctype html&gt;
&lt;html class=&quot;no-js&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
    &lt;base href=&quot;/&quot; /&gt;
    &lt;meta charset=&quot;utf-8&quot;&gt;
    &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
    &lt;meta name=&quot;google&quot; value=&quot;notranslate&quot;&gt;
    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, shrink-to-fit=no&quot;&gt;
    &lt;meta name=&quot;theme-color&quot; content=&quot;#000000&quot;&gt;
    &lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot; /&gt;
    &lt;link rel=&quot;manifest&quot; href=&quot;manifest.webapp&quot; /&gt;
    &lt;link rel=&quot;stylesheet&quot; href=&quot;static/css/loading.css&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;root&quot;/&gt;    
&lt;/body&gt;
&lt;/html&gt;

And does not load the js bundle. I couldnt see any clue in the browser and server logs.

答案1

得分: 0

我想你想要托管使用Maven构建的React.js前端和Java后端项目。但是,在Google Cloud Platform中将使用NPM构建的React.js项目和使用Maven构建的Java后端项目合并为一个可部署的包可能会比较困难。

因此,作为一种替代方法,您可以使用Google云平台中的App Engine项目内的微服务。您可以按照此教程来解决您的问题。

如果您只有一个React.js项目,那么在这里有一个教程,教您如何将React应用部署到Google Cloud App Engine。

英文:

I imagine that you want to host the React.js front-end and Java back end project that is build by maven. But It’s difficult to merge a React.js project built with NPM and a Java back-end project built with Maven into one deploy-able package in Google Cloud Patform.

So As an altenative, you can use Google microservices within an App engine project. You can follow this tutorial to solve your issue.

If you have only a Reactjs project so here is a tutorial, how to deploy React App to Google Cloud App Engine.

huangapple
  • 本文由 发表于 2020年1月6日 19:24:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/59611259.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定