Skip to content

Static files not being served when running app with 'ng serve' #6329

Closed
@TylerJBrown192

Description

@TylerJBrown192

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

$ ng --version
@angular/cli: 1.0.1
node: 6.9.1
os: win32 x64
@angular/common: 4.1.0
@angular/compiler: 4.1.0
@angular/core: 4.1.0
@angular/forms: 4.1.0
@angular/http: 4.1.0
@angular/platform-browser: 4.1.0
@angular/platform-browser-dynamic: 4.1.0
@angular/router: 4.1.0
@angular/cli: 1.0.1
@angular/compiler-cli: 4.1.0

Repro steps.

  1. Add a .txt or .json file anywhere in the project
  2. Add another in /src/assets/
  3. Run ng serve from the command line in the Angular application
  4. Open up the dev console and look for the files in the Sources tab OR set up a service to make a HTTP request to the file path you expect the static file to be at
  5. A 404 will occur

The log given by the failure.

N/A

Desired functionality.

Would like to be able to access static files within the Angular application.

Mention any other details that might be useful.

When building out an Angular v2 application (when Angular CLI was still in beta release) I was able to serve static text files inside of my /app directory and get them with Http.get('app/example-dir/test-file.json') from @angular/http

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions