Search code examples
phphtmllaravellaravel-blade

Setting 'Content-Type' to 'text/plain' turns the page background black and the text white


It's not really an issue but I was just curious as to why this happens, I tried googling it but haven't found an answer

here's the code:

Route::get('/hello', function () {
    return response("<h1>hello world</h1>")->header('Content-Type', 'text/plain');
});

Expected result: just the h1 tag along the text like a normal text bit in an html file


Solution

  • its ok browsers like chrome handle it like text file but if you use postman the result is different and it shows you html page just with big "hello world"

    infect browsers shown 'text/plain' content in <pre> tag ;)