Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

axtg's avatar
Level 5

Odd CORS issue

Hi,

I've been developing a API filter/ include relationship logic locally. It's here: https://app.moos.nu/api/v1/installations/?filter[client]=001&includeSensors&includeTracks

This works locally. But not remotely. My API client throws a 500 error, without body returned for the response. In my browser it says "CORS missing allow origin". If I remove the includeSensors and includeTracks bit it does work (feel free to try, I'll keep it open for now). Locally it both works. My cors config is the default as per below.

Any idea? I'm on an EC2 instance at AWS, running on Nginx.

    'paths' => ['api/*', 'graphql'],
    'allowed_methods' => ['*'],
    'allowed_origins' => ['*'],
    'allowed_origins_patterns' => [],
    'allowed_headers' => ['*'],
    'exposed_headers' => [],
    'max_age' => 0,
    'supports_credentials' => true,
0 likes
4 replies
MohamedTammam's avatar

It isn't a CORS issue. You're getting a 500 error on the back-end which responses without the proper CORS header.

Check your logs to see what causes the 500 error.

For me, it works if I just remove includeTracks.

axtg's avatar
Level 5

I've set environment to development and debug to true, but I'm not seeing any errors....

axtg's avatar
Level 5

Thanks for checking that too @mohamedtammam, appreciate it. The code for these two includes seems pretty basic. And I'm thrown off by the fact that it works locally, yet not remote. The relationship exists remotely too, with data.

I'll start Log:debug'ing, while pushing to the prod, but any help still appreciated.

        // Optionally load relationships
        if($request->has('includeSensors') && !$request->has('includeTracks'))
        {
            $installations->with('sensors');
        }

        if($request->has('includeTracks'))
        {
            $installations->with('sensors.tracks');
        }
```	
MohamedTammam's avatar

@axtg If that part is what causing the issue, can you please try.

if($request->has('includeSensors') && !$request->has('includeTracks'))
        {
            $installations->with('sensors');
        } else($request->has('includeTracks'))
        {
            $installations->with('sensors.tracks');
        }

Please or to participate in this conversation.