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

Console error: wp-json/custom-permalinks/v1/get-permalink/4556 401 (Unathorized) script-form-1.7.1.min.js?ver=5.7.2:1 #50

Open
mikehues opened this issue Jun 14, 2021 · 7 comments
Assignees

Comments

@mikehues
Copy link

Wordpress 5.7.2
Twenty Twenty-One 1.3
Custom Permalinks 1.7.1

I disabled all other plugins and created a new page. I edit the page and make a simple text change and click 'Update'. Shortly after the "Page update. View Page" message pops up at the bottom of the page, this error shows up in the console:

GET https://testsite.local//wp-json/custom-permalinks/v1/get-permalink/4556 401 (Unauthorized). script-form-1.7.1.min.js?ver=5.7.2:1
updateMetaBox | @ | script-form-1.7.1.min.js?ver=5.7.2:1
(anonymous) | @ | data.min.js?ver=9430…126df689839bb96b9:2
i | @ | data.min.js?ver=9430…126df689839bb96b9:2
.
.
.

The changes to the page content are successfully saved, so it doesn't pose much of a problem until you try to update the permalink. If you change the permalink and click 'Update', the same thing happens. But now, the 'View Page' links still point to the old permalink. If you click any of these links (top admin bar, Custom permalink metabox button & lower left 'page updated' popup) you get a page not found.

Please let me know if you need additional info.

thanks,

Mike

@samiahmedsiddiqui
Copy link
Owner

Hi @mikehues

Sorry for facing this issue. Can you please check whether this is still an issue for you or already fixed in the new version. I am not able to generate it in the new version. If you are still able to generate this issue then please let me know.

Thanks,
Sami

@mikehues
Copy link
Author

mikehues commented Aug 6, 2021

Hi Sami,

Sorry it took so long for me to reply. Looks like the issue is partly resolved with the new version.

updated versions:
Wordpress 5.8
Twenty Twenty One 1.4
Custom Permalinks 2.0.1

When I update the custom permalink, there is no longer an error in the console. Also, the 'View Page' button link in the Custom Permalinks metabox is updated correctly. But, the view page links in the top admin bar and the bottom popup still point to the previous permalink. After playing around for a bit, here are some observations I've made.

My expectations are based on the wordpress core behavior, which is as follows:

  1. I goto example.local/mens and I change the permalink slug from 'mens' to 'foo'
  2. The 'view page' links are updated and point to example.local/foo. I click the link and the page loads at the new permalink.
  3. if I goto the old permalink (example.local/mens) I get a 'page not found'

Here's a simple example which has unexpected, but acceptable results. (This wouldn't technically require the Custom Permalinks plugin, since there is no directory structure in this url.)

  1. I goto example.local/mens and I change the permalink to example.local/foo
  2. I click one of the links that still points to example.local/mens and I'm redirected to example.local/foo
  3. if I go back to the old permalink (example.local/mens) I'm redirected to example.local/foo

So, I don't get a 'page not found', when clicking the view page links, which is good. But, the redirect was unexpected.

Here's where I start to run into trouble:

  1. I goto example.local/foo and I change the permalink to example.local/bar
  2. I click one of the links that still points to example.local/foo and I get 'page not found'
  3. if I goto the original permalink (example.local/mens) I'm redirected to example.local/bar

Here's another example with a directory structure:

  1. I goto example.local/womens/place and I change the permalink to example.local/womens/test
  2. I click one of the links that still points to example.local/womens/place and the page loads at the old permalink
  3. if I goto the new permalink (example.local/womens/test) the page loads successfully.

So, now the page is available at two different urls, which is unexpected and not ideal.

Please let me know if I can provide anymore info.

thanks,

Mike

@samiahmedsiddiqui
Copy link
Owner

@mikehues Thank you for detailed reply.

Here's another example with a directory structure:

  1. I goto example.local/womens/place and I change the permalink to example.local/womens/test
  2. I click one of the links that still points to example.local/womens/place and the page loads at the old permalink
  3. if I goto the new permalink (example.local/womens/test) the page loads successfully.

In this case, old permalink should redirect to the new permalink instead of serving the page. (I will check if I am able to re-produce this issue on my end).

@samiahmedsiddiqui
Copy link
Owner

@mikehues I have released v2.2.0 that fixes couple of issues you have pointed. Can you please test your pointed issues with the v2.2.0?

@samiahmedsiddiqui samiahmedsiddiqui modified the milestone: 2.0.0 Aug 13, 2021
@mikehues
Copy link
Author

Hi Sami,

thanks for your work on this.

I just ran the same tests with version 2.2.0

I can confirm that, upon updating the permalink, all three 'View Page' links are updated to the new permalink. So, this has fixed the issue of clicking 'view page' and getting 'page not found' or seeing the page at the old permalink. But, if I manually type in the old permalink, the page loads successfully at that url instead of redirecting to the new url.

thanks,

Mike

@samiahmedsiddiqui
Copy link
Owner

But, if I manually type in the old permalink, the page loads successfully at that url instead of redirecting to the new url.

@mikehues old permalink means old customized permalink or WP permalink? Also, can you please test this after deactivating all the other plugins and switching to the default theme?

If you still able to crawl the old permalink then please provide me an example.

In actual, old customized permalink should not work and throws 404. Redirect needs to be manually added or wait for the next release in which I will add redirect functionality as well.

@mikehues
Copy link
Author

Hi Sami,

I did test with all other plugins disabled and using twentytwentyone theme. Old customized permalinks throw 404s as expected, but the original WP permalink still loads

I repeated this test with a directory structure:

  1. I goto example.local/womens/place and I change the permalink to example.local/womens/test
  2. All 'view page' links point to example.local/womens/test as expected <-- fixed in new version
  3. Change permalink again to example.local/womens/test-again
  4. I goto the new custom permalink - example.local/womens/test-again <-- the page loads successfully
  5. I goto the old custom permalink - example.local/womens/test <-- throws 404 as expected
  6. I goto the original WP permalink - example.local/womens/place <-- the page loads successfully. seems like it should redirect so the page is not available at two different urls

thanks,

Mike

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

No branches or pull requests

2 participants