Reputation: 438
I'm building a hub extension for Team Foundation Server 2015.
My Hub HTML page works fine until I switch over to use systemjs and angular2, at which point any script request coming from systemjs appears to be rejected with a 401 unauthorized.
I followed the Angular2 Quickstart guide closely and it all works fine locally without authentication.
But once I upload my application to TFS, any script requested by systemjs is rejected as seen below:
Error: XHR error (401 Unauthorized) loading http://tfs-server:8080/tfs/_apis/public/gallery/publisher/my-publisher/extension/source-extensions/1.1.2/assetbyname/scripts/main.js(…)
Zone.run @ angular2-polyfills.js:1243
zoneBoundFn @ angular2-polyfills.js:1220
lib$es6$promise$$internal$$tryCatch @ angular2-polyfills.js:468
lib$es6$promise$$internal$$invokeCallback @ angular2-polyfills.js:480
lib$es6$promise$$internal$$publish @ angular2-polyfills.js:451
lib$es6$promise$$internal$$publishRejection @ angular2-polyfills.js:401
(anonymous function) @ angular2-polyfills.js:123
Zone.run @ angular2-polyfills.js:1243
zoneBoundFn @ angular2-polyfills.js:1220
lib$es6$promise$asap$$flush @ angular2-polyfills.js:262
If I load my scripts via a script tag, there's no authorization issue. But when I do it via systemjs like this, it fails with the 401 error:
<script>
System.config({
packages: {
scripts: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('scripts/main.js')
.then(null, console.error.bind(console));
</script>
My question is this: When using systemjs to load scripts rather than loading them directly, is there something extra I have to do to avoid getting 401 unauthorized?
Upvotes: 1
Views: 2251
Reputation: 1422
SystemJS will use XHR to load code, which may somehow be the difference here.
If you want SystemJS to use <script> tag injection, try:
System.config({
packages: {
scripts: {
format: 'register',
defaultExtension: 'js',
scriptLoad: true
}
}
});
If it still happens with that, then it must be server configuration for sure.
Upvotes: 2