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

sitemap plugins don't work with playground #1186

Closed
rhildred opened this issue Apr 3, 2024 · 6 comments · May be fixed by #1203
Closed

sitemap plugins don't work with playground #1186

rhildred opened this issue Apr 3, 2024 · 6 comments · May be fixed by #1203
Labels
[Type] Enhancement New feature or request

Comments

@rhildred
Copy link

rhildred commented Apr 3, 2024

The request is handled as though it is for a static file in packages/php-wasm/universal/src/lib
/php-request-handler.ts.

function seemsLikeAPHPFile(path: string) {
	return path.endsWith('.php') || path.includes('.php/');
}

The leading sitemap plugins generate sitemap.xml on request, so give a 404 error on playground.

@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 3, 2024

@rhildred how is this different from normal PHP behaviour?

@adamziel
Copy link
Collaborator

adamziel commented Apr 3, 2024

Would setting a permalink structure in WordPress settings help here at all?

@adamziel
Copy link
Collaborator

adamziel commented Apr 3, 2024

Aha, I think I understand it better now. A rewrite rule from sitemap.xml to index.php (why index? not sure, need to inspect those plugins) may be needed to solve this.

@adamziel adamziel added the [Type] Enhancement New feature or request label Apr 3, 2024
@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 4, 2024

@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 4, 2024

@rhildred
Copy link
Author

rhildred commented May 14, 2024

I was able to get it to work by using run rather than request in my bundler.

        if (this.seemsLikeAPHPRequestHandlerPath(fsPath) || php.fileExists(fsPath)) {
            return(php.request(request));
        }else{
            // we need to do a run here
            const scriptPath = `${this.requestHandler.documentRoot}/index.php`;
            console.log(scriptPath);
            return(php.run({
				relativeUri: requestedUrl.pathname,
				protocol: (requestedUrl.protocol || '').replace(':', ''),
				method: request.method || 'GET',
				$_SERVER: {
					REMOTE_ADDR: '127.0.0.1',
					DOCUMENT_ROOT: this.requestHandler.documentRoot,
					HTTPS: request.url.startsWith('https://')
						? 'on'
						: '',
				},
				body: request.body,
				scriptPath,
				headers: request.headers,
			}));
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants