Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 403 when loading the component #8

Closed
dpdragnev opened this issue Mar 8, 2017 · 8 comments
Closed

Getting 403 when loading the component #8

dpdragnev opened this issue Mar 8, 2017 · 8 comments
Assignees
Labels

Comments

@dpdragnev
Copy link

Hello,

Here is my main module:
`import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { BlockUIModule } from 'ng-block-ui';

import { AppComponent } from './components/app.component/app.component';

@NgModule({
imports: [
BrowserModule,
BlockUIModule
],
declarations: [
AppComponent
],
providers: [],
entryComponents: [],
bootstrap: [AppComponent]
})
export class AppModule { }`

When I run the app, I am getting:

http://site-url/node_modules/ng-block-ui/ 403 (Forbidden)

I have never seen this before. Any idea what could be the problem.

Thank you.

@kuuurt13
Copy link
Owner

kuuurt13 commented Mar 9, 2017

Hey @dpdragnev, can you give me a little info on your setup? As in what are you using to build your app like webpack, angular-cli, etc? The reason I ask is because this may be a issue with your setup. If you can give me some more info that would help me narrow down the issue.

@kuuurt13 kuuurt13 added the bug label Mar 9, 2017
@kuuurt13 kuuurt13 self-assigned this Mar 9, 2017
@dpdragnev
Copy link
Author

dpdragnev commented Mar 9, 2017

I suspect that you are right, but I cannot figure out what I am missing.

Index.html: just the head

<head>
	<title>App</title>

	<base href="/">
	<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width" />    

	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
	<link href="~/Styles/site.css" rel="stylesheet" />

	<script src="node_modules/core-js/client/shim.min.js"></script>
	<script src="node_modules/zone.js/dist/zone.js"></script>
	<script src="node_modules/systemjs/dist/system.src.js"></script>
	<script src="systemjs.config.js"></script>

	<script>
      System.import('main.js').catch(function(err){ console.error(err); });
	</script>
</head>

package.json:

{
  "name": "myapp",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "dependencies": {
    "@angular/common": "~2.4.0",
    "@angular/compiler": "~2.4.0",
    "@angular/core": "~2.4.0",
    "@angular/forms": "~2.4.0",
    "@angular/http": "~2.4.0",
    "@angular/platform-browser": "~2.4.0",
    "@angular/platform-browser-dynamic": "~2.4.0",
    "@angular/router": "~3.4.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.20",
    "angular-in-memory-web-api": "~0.2.4",
    "core-js": "^2.4.1",
    "ng-block-ui": "^1.0.0-beta.1",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.7.4"
  },
  "devDependencies": {
    "concurrently": "^3.2.0",
    "lite-server": "^2.2.2",
    "typescript": "~2.0.10",
    "canonical-path": "0.0.2",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36"
  },
  "author": "author",
  "license": "ISC"
}

system.config.js:

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
	System.config({
		baseURL: '.',
		paths: {
			// paths serve as alias
			'npm:': 'node_modules/'
		},
		// map tells the System loader where to look for things
		map: {
			// our app is within the app folder
			app: 'app',

			// angular bundles
			'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
			'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
			'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
			'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
			'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
			'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
			'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
			'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

			// other libraries
			'rxjs': 'npm:rxjs',
			'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
			'ng-block-ui': 'npm:ng-block-ui'
		},
		// packages tells the System loader how to load when no filename and/or no extension
		packages: {
			app: {
				defaultExtension: 'js'
			},
			rxjs: {
				defaultExtension: 'js'
			}
		}
	});
})(this);

App.Module:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { BlockUIModule } from 'ng-block-ui';

import { AppComponent } from './components/app.component/app.component';


@NgModule({
	imports: [
		BrowserModule,
	],
	declarations: [
		AppComponent
	],
	providers: [],
	entryComponents: [],
	bootstrap: [AppComponent]
})
export class AppModule { }

Thank you for your help.

@dpdragnev
Copy link
Author

sorry, I am not sure why the formatting is so messed up. Kind of hard to read. Let me know if you want me to send you the whole files.

@kuuurt13
Copy link
Owner

kuuurt13 commented Mar 9, 2017

@dpdragnev No problem, I fixed the formatting for you in your comment. With code blocks you normally need to add ``` instead of ` to get it to format nicely.

Thanks for the extra info. Looks like you are using systemjs which I currently don't have support for but I have been meaning to look into. Give me a few minutes and I will try to put together a PR with something that should work for you.

kuuurt13 added a commit that referenced this issue Mar 9, 2017
task(lib): Added systemjs support (#8)
@dpdragnev
Copy link
Author

Thanks @kuuurt13 . I really appreciate your quick responses and help.

@kuuurt13
Copy link
Owner

kuuurt13 commented Mar 9, 2017

@dpdragnev, I just merged #9 which should add systemjs support. I also published a new version to npm ng-block-ui@0.3.2. Please update your ng-block-ui version to 0.3.2 in your app. Once you have the latest version you will need to make some changes to your system.config.js file, see below.

Updates:

  • Updated your 'map' to point to the ng-block-ui umd bundle
  • Add ng-block-ui to your packages to resolve the index file. (You will need the single quotes because of the hyphens in the package name)

Give this a shot and let me know if it works. Let me know if you have any questions.

/**
 * System configuration for Angular samples
 * Adjust as necessary for your application needs.
 */
(function (global) {
  System.config({
    baseURL: '.',
    paths: {
      // paths serve as alias
      'npm:': 'node_modules/'
    },
    // map tells the System loader where to look for things
    map: {
      // our app is within the app folder
      app: 'app',

      // angular bundles
      '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
      '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
      '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
      '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
      '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
      '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
      '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
      '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',

      // other libraries
      'rxjs': 'npm:rxjs',
      'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
      'ng-block-ui': 'npm:ng-block-ui/bundles/umd'  // Point to the umd bundle
    },
    // packages tells the System loader how to load when no filename and/or no extension
    packages: {
      app: {
        defaultExtension: 'js'
      },
      rxjs: {
        defaultExtension: 'js'
      },
      'ng-block-ui': { main: 'index.js', defaultExtension: 'js' } // Resolve index.js 
    }
  });
})(this);

@dpdragnev
Copy link
Author

Awesome. Thank you so much. I will get this done in the morning and will report back.

@dpdragnev
Copy link
Author

@kuuurt13 After following your instructions, everything worked as expected. Thank you for your quick response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants