【发布时间】:2020-11-14 07:32:36
【问题描述】:
我正在尝试使用 cPanel 在我的共享托管服务上部署应用程序。
我的提供商在面板中有经典的“设置节点 js 应用程序”,我用它在 mywebsite.com/api 路径下激活我的应用程序。
我还在 public_html 下使用以下 .htaccess 托管了我的 Angular 前端
<IfModule mod_rewrite.c>
DirectoryIndex disabled
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
我的前端应用程序可以工作,但是当我尝试向我的后端发送 POST 请求时,即(mywebsite/api/login)它会返回 html 前端作为响应。
这是它返回的内容:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>my frontend app</title>
<base href="./">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="assets/favicon.ico">
</head>
<body>
<app-root></app-root>
<script src="runtime-es2015.js" type="module"></script>
<script src="runtime-es5.js" nomodule defer></script>
<script src="polyfills-es5.js" nomodule defer></script>
<script src="polyfills-es2015.js" type="module"></script>
<script src="styles-es2015.js" type="module"></script>
<script src="styles-es5.js" nomodule defer></script>
<script src="scripts.js" defer></script>
<script src="vendor-es2015.js" type="module"></script>
<script src="vendor-es5.js" nomodule defer></script>
<script src="main-es2015.js" type="module"></script>
<script src="main-es5.js" nomodule defer></script>
</body>
</html>
我错过了什么吗?
顺便说一句:
- 我的前端托管在 mywebsite.com 下
- 我的后端托管在 mywebsite.com/api 下
- 我所有的 Angular 服务都指向 /api/*
当我从 mywebsite.com/api 访问我的后端时,我得到了这个:
【问题讨论】:
标签: node.js angular deployment hosting cpanel