我正在尝试将angular 7网站部署到无服务器的AWS上。刚开始时,我遵循了本教程:https : //coursetro.com/posts/code/165/Deploying-your-Angular-App-to-a-Serverless-Environment-
部署后,我的url附加了一个额外的“ production / ”,我认为这是由于我的base-href设置所致。
这会导致不必要的重定向到404。有人知道如何避免这种情况吗? 导航菜单效果很好
输入的网址:
https://7z48go76gd.execute-api.ap-southeast-1.amazonaws.com/production
加载后:
https://7z48go76gd.execute-api.ap-southeast-1.amazonaws.com/production/production
我尝试过环境.prod.ts,environment.serverless.ts以及具有不同变体但没有运气的package.json文件。
environment.serverless.ts / environment.prod.ts:
export const environment = {
production: true,
BASE_URL: 'https://tj2rdz0qn1.execute-api.ap-southeast-1.amazonaws.com/production',
// when you deploy your app to your own server you should replace the BASE_URL with the target domain for example:
// BASE_URL: 'https://site-preview.angular-templates.io',
baseHref: '/'
};
Run Code Online (Sandbox Code Playgroud)
package.json:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"lint": "ng lint crc-web",
"build:client-and-server-bundles": "ng build --prod && ng run crc-web:server:production",
"build:ssr": "npm …Run Code Online (Sandbox Code Playgroud)