build: Karma proxy should convert Host header
authorAntoine Musso <hashar@free.fr>
Tue, 20 Dec 2016 15:46:20 +0000 (16:46 +0100)
committerKrinkle <krinklemail@gmail.com>
Fri, 23 Dec 2016 01:56:26 +0000 (01:56 +0000)
By default the Karma proxy does requests against 'localhost', however
if the target wiki server has strict host validation (e.g. multiple
virtual hosts or otherwise strictly verified) then requests may fail
since load.php is not found. An example is with MW_SERVER=devwiki.local.

MediaWiki-Vagrant and Wikimedia CI are not affected since they use
'localhost' as the virtual host.

Set Karma proxy to change the hostname accordingly.

Reference:
 https://github.com/karma-runner/karma/issues/1729
 https://github.com/karma-runner/karma/commit/ae05ea4

Bug: T153757
Change-Id: I317d5686aecd1fb6cf6921cdca77670cded85607

Gruntfile.js

index 55b7932..7b3af54 100644 (file)
@@ -14,7 +14,10 @@ module.exports = function ( grunt ) {
        grunt.loadNpmTasks( 'grunt-karma' );
        grunt.loadNpmTasks( 'grunt-stylelint' );
 
-       karmaProxy[ wgScriptPath ] = wgServer + wgScriptPath;
+       karmaProxy[ wgScriptPath ] = {
+               target: wgServer + wgScriptPath,
+               changeOrigin: true
+       };
 
        grunt.initConfig( {
                eslint: {