简体   繁体   English

构建和上传项目时在服务器中找不到文件

[英]not found file in server when build and uplaod project

i have a project in angular 9 and asp core 3.我在 angular 9 和 asp core 3 中有一个项目。

this is addres of site: http://mag-testcpl.astromap.ir/这是网站地址: http://mag-testcpl.astromap.ir/

and it show me this error:它告诉我这个错误:

http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css

and this is in my html:这是在我的 html 中:

<head>
<meta charset="utf-8">
<title>Astronomy Mag | Admin panel</title>
<base href="/app">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="./assets/media/logos/favicon.png">
<link id="mainStyle" href="./assets/css/demo1/style.bundle.main.css" rel="stylesheet">
<link id="ltrStyle" href="./assets/css/demo1/style.bundle.css" rel="stylesheet">
<link id="rtlStyle" href="./assets/css/demo1/style.bundle.rtl.css" rel="stylesheet">
<link id="toaster" href="./assets/vendors/global/toastr.css" rel="stylesheet">

<style>

</style>

when i enter this url in brwoser http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css it not show me any things but when i enter this url in by this http://mag-testcpl.astromap.ir/app/assets/vendors/global/toastr.css when i enter this url in brwoser http://mag-testcpl.astromap.ir/assets/vendors/global/toastr.css it not show me any things but when i enter this url in by this http://mag-testcpl.astromap.ir/app/assets/vendors/global/toastr.css

add /app to url将 /app 添加到 url

it's worked and show me file.它的工作,并显示我的文件。

i build the project with this command ng build --prod --base-href /app我用这个命令构建项目ng build --prod --base-href /app

how can i solve this problem?????我怎么解决这个问题?????

   "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/avastar",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.app.json",
        "assets": [
          "src/favicon.png",
          "src/assets"
        ],
        "styles": [
          "src/styles.scss",
          "./node_modules/quill/assets/snow.styl",
          "./node_modules/quill/assets/core.styl",
          "./node_modules/quill/assets/bubble.styl"
        ],
        "scripts": [
          "src/assets/vendors/global/vendors.bundle.js",
          "src/assets/js/demo1/scripts.bundle.js"
        ],
        "stylePreprocessorOptions": {
          "includePaths": [
            "src",
            "src/stylings/",
            "src/stylings/base/",
            "src/stylings/kt-customs/"
          ]
        },
        "es5BrowserSupport": true
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": false,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": false,
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "5mb",
              "maximumError": "10mb"
            }
          ]
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
        "browserTarget": "avastar:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "avastar:build:production"
        }
      }
    },
    "extract-i18n": {
      "builder": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "avastar:build"
      }
    },
    "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.spec.json",
        "karmaConfig": "src/karma.conf.js",
        "styles": [
          "src/styles.scss"
        ],
        "scripts": [],
        "assets": [
          "src/assets"
        ]
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "src/tsconfig.app.json",
          "src/tsconfig.spec.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    }
  }

Let's first understand what is base href我们先来了解一下什么是base href

if you wan to use different base paths for router and static assets.如果您想对路由器和 static 资产使用不同的基本路径。 Angular makes use of the base href to tell router how to compose navigation URLs. Angular 使用基本 href 来告诉路由器如何编写导航 URL。 If your application exists at the root, then you can use / as the href value as shown.如果您的应用程序存在于根目录,那么您可以使用 / 作为 href 值,如图所示。 <base href="/"> ==> HTML <base href="/"> ==> HTML

I wanted to use /users as my application base for router and /public as base for my assets.我想使用/users作为路由器的应用程序基础,并使用/public作为我的资产的基础。 <base href="/users"> && <link href="/public/styles.xxxx.bundle.css" rel="stylesheet"/> <base href="/users"> && <link href="/public/styles.xxxx.bundle.css" rel="stylesheet"/>

So you must use this command ng build -prod --base-href /users --deploy-url /public所以你必须使用这个命令ng build -prod --base-href /users --deploy-url /public

The answer is do you really need to append app to your route?答案是你真的需要 append app到你的路线吗? if no just use ng build --prod如果没有,只需使用ng build --prod

Hope it helps希望能帮助到你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试将 PDF 文件上传到 React-native 中的服务器时出错 - Get error when try to uplaod PDF file to server in React-native React中的axios不会将信息发送到Express服务器(文件更新) - axios in React isnt sending info to Express server (Files uplaod) 无法构建 React/Next 项目 - 找到没有 React 组件的页面作为默认导出(上下文 api 文件) - Can't build React/Next project - found page without a React Component as default export (context api file) 使用ASP文件上传器上传超过4 MB的图片? - Uplaod image over 4 mb using asp file uploader? 当我运行ng build时,如何配置服务器部分或前端以避免找不到错误404 - How to configure the server part or frontend to avoid the error not found 404 when I run ng build 如何从选定的(复选框)列表视图获取价值并升级到服务器jQuery Mobile - how to get value from selected (checkbox) listview and uplaod to server jquery mobile 在Spring项目中找不到Javascript文件 - Javascript file not found inside spring project 在Dynamics CRM项目文档中找不到文件 - File cannot be found in Dynamics CRM project documents 如何将此项目构建为单个Javascript文件? - How to build this project into a single Javascript file? dojo/cordova 项目的单层构建文件 - Single layer build file for a dojo/cordova project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM