Added some headers

This commit is contained in:
neerholt 2021-03-19 09:18:19 +01:00
parent 815ec2d499
commit c1484e4710
7 changed files with 38 additions and 10 deletions

View File

@ -14,6 +14,7 @@ if(isset($_GET['gameDataId'])){
$openGameDataStream = GameData::all();
}
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
header('Content-Type: application/json;charset=UTF-8');
echo $openGameDataStream->toJson(JSON_PRETTY_PRINT);

View File

@ -9,8 +9,9 @@ if(isset($_GET['gameJamId'])){
$dbValue = GameJam::all();
}
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
header('Content-Type: application/json;charset=UTF-8');
echo $dbValue->toJson(JSON_PRETTY_PRINT);
//var_dump(headers_list());

View File

@ -12,5 +12,7 @@ else{
$groups = Group::all();
}
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
header('Content-Type: application/json;charset=UTF-8');
echo $groups->toJson(JSON_PRETTY_PRINT);

View File

@ -21,6 +21,9 @@ if(isAdmin() && isset($_GET['gameJamId'])){
$winningGroups->push($group);
}
}
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
header('Content-Type: application/json;charset=UTF-8');
echo $winningGroups->toJson(JSON_PRETTY_PRINT);

View File

@ -8,14 +8,16 @@ use \Backend\Models\GameJam;
use \Illuminate\Support\Collection;
if (!isAdmin()){
if(isset($_POST['genKeyWord'])){
$gameJamId = $_POST['gameJamId'];
if(isset($_GET['genKeyWord'])){
$gameJamId = $_GET['gameJamId'];
$game_jam = GameJam::find($gameJamId);
$all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray();
$find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get();
$game_jam->key_word = $find_all_keywords->first()->key_word;
$game_jam->save();
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept");
header('Content-Type: application/json;charset=UTF-8');
echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT);
}

View File

@ -33,6 +33,21 @@ $gameJam = GameJam::firstOrCreate([
<input type="submit" name="login" value="login">
</form>
<?php
//print_r(headers_list());
$h = apache_request_headers();
foreach ($h as $name => $value) {
echo "$name: $value <br>";
}
echo "<br>";
var_dump(headers_list());
?>
</body>
</html>

View File

@ -6,10 +6,14 @@ $(window).on("load", function(){
function dataFetch(){
$.ajax({
type: "GET",
url: "/Game-Jaming/Backend/Controllers/FileHandler/GetGameData.php?gameJamId=1",
url: "/Game-Jaming/Backend/controllers/GameJam/GetGameJam.php",
success: function(result){
console.log(result);
console.log(result[0].game_link)
console.log(result[0].name);
}
});
}
//console.log(result.name); ?gameJamId=1
//console.log(result[0].name); uden ?gameJamId=1