Replies: 8 comments
-
@diogo-vf are you sure above code works for you ? i had to make few changes to run it locally. I don't see any spaces. Route::any('exports/{channel}/{type?}', function ($channel, $type = null) {
$content = <<<XML
<?xml version="1.0"?>
<catalog>
<!-- Your XML content goes here -->
</catalog>
XML;
return response($content, 200)
->header('Content-Type', 'application/xml');
})->name('exports');
|
Beta Was this translation helpful? Give feedback.
-
@vjaykoogu Hi, I have 'auth:sactum' middleware at the top level of my Route::middleware(['auth:sanctum'])
->group(function () {
Route::any('exports/{channel}/{type?}', `myCallback` )->name('exports');
Route::post( [...] );
[...]
}); |
Beta Was this translation helpful? Give feedback.
-
@diogo-vf could you please try in different browser?, This is what i see on my machine. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@diogo-vf Forgot to add Safari Result, I dint make any changes i can see the same on safari too. (my previous screenshot is from Brave browser) |
Beta Was this translation helpful? Give feedback.
-
I use Firefox as my main browser But i can't understand why in your case, you don't have 4spaces when calling the "export" |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
To bypass the problem, when I run |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
11.0 and 11.25
PHP Version
8.2.22
Database Driver & Version
No response
Description
After calling my custom api route and asking an xml response, it return every time at the first line 4 spaces following by a
\n
.During my tests, I use the followin XML: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms762271(v=vs.85)
the code in the API route file:
The answer:
But when I remove the header
Content-Type
, the first line is correctly<?xml version="1.0"?>
, but the Content-Type is text/html; charset=UTF-8.Steps To Reproduce
Add the following route in the
routes/api.php
file:Call
backend.laravel.vm/api/exports/demo
and you're result should be:Beta Was this translation helpful? Give feedback.
All reactions