Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

downloaded index.php instead of load the app #509

Open
reregin opened this issue Dec 12, 2023 · 15 comments
Open

downloaded index.php instead of load the app #509

reregin opened this issue Dec 12, 2023 · 15 comments

Comments

@reregin
Copy link

reregin commented Dec 12, 2023

hi, i'm a total beginner and i want to deploy my laravel app on vercel. i was planning to connect it to Oracle ATP to use it as the database. but i'm totally stuck on the vercel. when i open the website, it downloaded the index.php instead of load the app.

this is how my project looks like

project
├── .vercel
│   ├── ...
├── .vercelignore
├── api
│   └── index.php
...
├── public
│   ├── .htaccess
│   ├── favicon.ico
│   ├── index.php
│   └── robots.txt
...
├── vercel.json
└── vite.config.js

i already included functions and routes on my vercel.json like this:

"functions": {
        "api/*.php": {
            "runtime": "[email protected]"
        }
    },
    "routes": [
        {
          "src": "/(.*)",
          "dest": "/api/index.php"
        }
    ],

and i point the /api/index.php to my original index.php like this:

<?php

// Forward Vercel requests to normal index.php
require __DIR__ . '/../public/index.php';

but it just downloaded the /api/index.php instead. do anyone has any ideas what happened? and are they more informations that i could give to help?

@DmitryAdam
Copy link

it's seems like the htaccess issue,
have you tried to remove the htaccess firest?

@reregin
Copy link
Author

reregin commented Dec 13, 2023

what do you mean by htaccess firest?

@solamichealolawale
Copy link

solamichealolawale commented Feb 9, 2024

I have this same issue for vanilla PHP with no build or framework. I don't know what to do again. In my case, I don't have any .htaccess file

vercel.json

{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  }
}

api/index.php

<?php

// Forward Vercel requests to normal index.php
require __DIR__ . '../index.php';

Here is my project structure

project
└── api
     └── index.php
└── css
└── fonts
└── images
└── js
└── index.php
└── other_php_pages.php
└── vercel.json

@f3l1x
Copy link
Collaborator

f3l1x commented Feb 9, 2024

@solamichealolawale Can you show me repository and public vercel URL?

@solamichealolawale
Copy link

solamichealolawale commented Feb 9, 2024

@solamichealolawale
Copy link

@f3l1x
Copy link
Collaborator

f3l1x commented Feb 25, 2024

I was fixing other bug, now it's time for your app. :-)

@moghwan
Copy link

moghwan commented Mar 21, 2024

bump, bug still occurring with Laravel and PHP runtimes 0.7.0 & 0.6.1

@moghwan
Copy link

moghwan commented Mar 21, 2024

fixed on my end, at vercel level I've set output directory value to api .

@solamichealolawale
Copy link

I was fixing other bug, now it's time for your app. :-)

@f3l1x any update on this?

@lukman-fun
Copy link

i have the same face

@mrezayusufy
Copy link

Everything is ok. You just need to deploy it to production.
vercel --prod

@sekedus
Copy link

sekedus commented Jul 23, 2024

Move all .php files to /api and update vercel.json:

vercel.json

{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  },
  "rewrites": [
    { "source": "/api/(.*)", "destination": "/api/$1" }
  ]
}

project structure:

project
└── api
     └── index.php
     └── other_php_pages.php
└── css
└── fonts
└── images
└── js
└── vercel.json

@f3l1x
Copy link
Collaborator

f3l1x commented Oct 19, 2024

Hi, I am not facing that issue anymore. Do you guys?

@tao
Copy link

tao commented Oct 19, 2024

I think this happened to me when the build outputDirectory was set to . instead of public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants