Skip to content

Commit

Permalink
Fix zeppelin-web development mode
Browse files Browse the repository at this point in the history
### What is this PR for?

After #2373, zeppelin-web dev mode does not work properly.
Dev mode always ask user login (even if authentication is turned off) and any login attempt will fail. So it makes difficult to develop front-end.

This PR fixes problem by not adding `X-Requested-With: XMLHttpRequest` header in dev mode.

### What type of PR is it?
Bug Fix

### Todos
* [x] - Fix devmode

### How should this be tested?
run zeppelin-web dev mode and see if you can login / open notebook

### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no

Author: Lee moon soo <[email protected]>

Closes #2463 from Leemoonsoo/fix_devmode and squashes the following commits:

073c128 [Lee moon soo] fix indent
bf15efc [Lee moon soo] do not apply X-Requested-With : XMLHttpRequest header in dev mode
  • Loading branch information
Leemoonsoo committed Jul 5, 2017
1 parent f36b1a1 commit 0443b00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
32 changes: 17 additions & 15 deletions zeppelin-web/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,23 +146,25 @@ let zeppelinWebApp = angular.module('zeppelinWebApp', requiredModules)
})

// handel logout on API failure
.config(function ($httpProvider, $provide) {
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
$provide.factory('httpInterceptor', function ($q, $rootScope) {
return {
'responseError': function (rejection) {
if (rejection.status === 405) {
let data = {}
data.info = ''
$rootScope.$broadcast('session_logout', data)
.config(function ($httpProvider, $provide) {
if (process.env.PROD) {
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
}
$provide.factory('httpInterceptor', function ($q, $rootScope) {
return {
'responseError': function (rejection) {
if (rejection.status === 405) {
let data = {}
data.info = ''
$rootScope.$broadcast('session_logout', data)
}
$rootScope.$broadcast('httpResponseError', rejection)
return $q.reject(rejection)
}
$rootScope.$broadcast('httpResponseError', rejection)
return $q.reject(rejection)
}
}
})
$httpProvider.interceptors.push('httpInterceptor')
})
$httpProvider.interceptors.push('httpInterceptor')
})
.constant('TRASH_FOLDER_ID', '~Trash')

function auth () {
Expand All @@ -177,7 +179,7 @@ function auth () {
},
crossDomain: true
})
let config = {headers: { 'X-Requested-With': 'XMLHttpRequest' }}
let config = (process.env.PROD) ? {headers: { 'X-Requested-With': 'XMLHttpRequest' }} : {}
return $http.get(baseUrlSrv.getRestApiBase() + '/security/ticket', config).then(function (response) {
zeppelinWebApp.run(function ($rootScope) {
$rootScope.ticket = angular.fromJson(response.data).body
Expand Down
1 change: 1 addition & 0 deletions zeppelin-web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ module.exports = function makeWebpackConfig () {
HELIUM_BUNDLE_DEV: process.env.HELIUM_BUNDLE_DEV,
SERVER_PORT: serverPort,
WEB_PORT: webPort,
PROD: isProd,
BUILD_CI: (isCI) ? JSON.stringify(true) : JSON.stringify(false)
}
})
Expand Down

0 comments on commit 0443b00

Please sign in to comment.