Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Expo Web App in a Subdirectory Results in Wrong URL #52

Open
Siyavoshi opened this issue Aug 16, 2020 · 2 comments
Open

Expo Web App in a Subdirectory Results in Wrong URL #52

Siyavoshi opened this issue Aug 16, 2020 · 2 comments

Comments

@Siyavoshi
Copy link

Hi,
I've opened this same issue on Expo's repo as well to no avail.

I'm using react-navigation v4 + @react-navigation/web alongside Expo 38 bare workflow.
I added "homepage": "http://localhost/mypwa/" to the package.json file.
I run expo build:web then copy the contents of web-build to WAMP's www/mypwa/ folder.

When I open up my PWA, the project starts just fine but the URL is incorrect.
Same results for when I run yarn web.
I expect the first URL to be localhost/mypwa/LoginScreen but it's actually localhost/LoginScreen.
Now this doesn't ruin my pwa or anything since I can navigate through the app just fine.
The problem is when I "Add to Home Screen" the URL, my website's main page is added to the homescreen instead of the PWA.

I also implemented react navigation's web container:
const AppContainer = isWeb ? createBrowserApp(AppSwitchNavigator) : createAppContainer(AppSwitchNavigator);

I haven't modified webpack.config.js since I don't know enough about webpack.

@AlexGrafe
Copy link

I'm using React Navigation v5 and have homepage: https://mydomain.com/subdirectory which works initially but still, the routing immediately goes to the NotFound route. Even with the below prefix it does not work:

const linking = {
  prefixes: ['https://mydomain.com/subdirectory', 'myapp://'],
};

This page describes the situation a bit, but not directly:
https://reactnavigation.org/docs/configuring-links#mapping-path-to-route-names

@satya164
Copy link
Member

satya164 commented Oct 18, 2020

@AlexGrafe this repo is for old versions of React Navigation. For anything related to latest versions React Navigation, you should open an issue in the main repo.

Regarding your problem, as mentioned in docs, prefixes is only used on Android and iOS. https://reactnavigation.org/docs/navigation-container#linkingprefixes

You should make subdirectory/ part of your path config itself. For example: instead of Home: 'home', use Home: 'subdirectory/home'

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

No branches or pull requests

3 participants