# Access-Control-Allow-Origin header in CLI server

- Thread: https://externals.io/message/68070
- Original archive: https://news-web.php.net/php.internals/68070
- Started by Daniel Lowrey on 2013-07-05T22:48:32+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #68070 — Daniel Lowrey — 2013-07-05T22:48:32+00:00

URL: https://externals.io/message/68070#68070

This is not the sort of thing that belongs in an HTTP server by
default. It's a one-off header that some users may elect to send but
the vast majority will not. If you need to simulate the feature of an
third-party server mod/plugin you should manually make a
`header('Access-Control-Allow-Origin: ...')` as needed in your
development code.

From an HTTP standpoint, baking this directly into the CLI server
doesn't make much sense IMO.

---

## #68071 — Matthew Leverton — 2013-07-05T23:34:49+00:00

URL: https://externals.io/message/68070#68071 · In reply to: #68070

> This is not the sort of thing that belongs in an HTTP server by
> default. It's a one-off header that some users may elect to send but
> the vast majority will not.
>
Of course I agree if you were speaking about a production web server.

--
Matthew Leverton

---

## #68072 — Mario Brandt — 2013-07-06T12:59:00+00:00

URL: https://externals.io/message/68070#68072 · In reply to: #68071

You can use the router script to add that header of your desire into
every request.


Cheers
Mario


> 
> > […]
> Of course I agree if you were speaking about a production web server.
>
> --
> Matthew Leverton

---

## #68073 — Matthew Leverton — 2013-07-06T17:07:19+00:00

URL: https://externals.io/message/68070#68073 · In reply to: #68072

> You can use the router script to add that header of your desire into
> every request.
>
That's what I currently do. And I agree that if somebody wants to
deviate from the reasonable set of defaults that PHP provides, then he
must set them in a router script. I don't think the CLI server should
be a configurable web server.

But IMO, this is no different from PHP maintaining and delivering a
small set of Content-type headers. Of course you could take the same
hardline approach and tell the developer to set all of the content
headers himself because you're worried that somebody might use PNG as
a data file that holds ping pong scores. But neither the existence of
this nor the content-type have any reasonable side effects.

I'm just throwing this out here; I've got nothing more to say and am
fine with the powers-to-be doing whatever they feel appropriate.

--
Matthew Leverton

---

## #68179 — Yasuo Ohgaki — 2013-07-19T00:03:50+00:00

URL: https://externals.io/message/68070#68179 · In reply to: #68073

Hi Matthew,

2013/7/7 Matthew Leverton <leverton@gmail.com>

> 
> > […]
> That's what I currently do. And I agree that if somebody wants to
> deviate from the reasonable set of defaults that PHP provides, then he
> must set them in a router script. I don't think the CLI server should
> be a configurable web server.
>
> But IMO, this is no different from PHP maintaining and delivering a
> small set of Content-type headers. Of course you could take the same
> hardline approach and tell the developer to set all of the content
> headers himself because you're worried that somebody might use PNG as
> a data file that holds ping pong scores. But neither the existence of
> this nor the content-type have any reasonable side effects.
>
> I'm just throwing this out here; I've got nothing more to say and am
> fine with the powers-to-be doing whatever they feel appropriate.


It would be nice if PHP encourages secure web application development.

Not only having

 Access-Control-Allow-Origin

but also

  'X-Frame-Options' => 'SAMEORIGIN',
  'X-XSS-Protection' => '1; mode=block',
  'X-Content-Type-Options' => 'nosniff'

headers are best practice for better security.
It may not be suitable as PHP core setting. However, it would
be great for many users to have these as new core module setting.
PHP would be better if PHP promotes secure app development.

Number of recommended HTTP headers may increase.
Perhaps, we should have php.ini entry that specify any HTTP headers
and set defaults in php.ini-*

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net
